reflex 0.7.0a1__py3-none-any.whl → 0.7.0a3__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/pages/utils.js.jinja2 +1 -1
- reflex/app.py +6 -8
- reflex/components/base/app_wrap.pyi +16 -16
- reflex/components/base/body.pyi +16 -16
- reflex/components/base/document.pyi +76 -76
- reflex/components/base/error_boundary.pyi +17 -21
- reflex/components/base/fragment.pyi +16 -16
- reflex/components/base/head.pyi +31 -31
- reflex/components/base/link.pyi +31 -31
- reflex/components/base/meta.pyi +61 -61
- reflex/components/base/script.pyi +19 -19
- reflex/components/base/strict_mode.pyi +16 -16
- reflex/components/core/banner.py +95 -19
- reflex/components/core/banner.pyi +91 -91
- reflex/components/core/client_side_routing.pyi +31 -31
- reflex/components/core/clipboard.pyi +17 -20
- reflex/components/core/debounce.pyi +17 -17
- reflex/components/core/foreach.py +5 -0
- reflex/components/core/html.pyi +16 -16
- reflex/components/core/sticky.pyi +61 -61
- reflex/components/core/upload.pyi +80 -88
- reflex/components/datadisplay/code.pyi +31 -31
- reflex/components/datadisplay/dataeditor.pyi +40 -54
- reflex/components/datadisplay/shiki_code_block.pyi +46 -46
- reflex/components/el/element.pyi +16 -16
- reflex/components/el/elements/base.pyi +16 -16
- reflex/components/el/elements/forms.pyi +222 -256
- reflex/components/el/elements/inline.pyi +421 -421
- reflex/components/el/elements/media.pyi +376 -376
- reflex/components/el/elements/metadata.pyi +91 -91
- reflex/components/el/elements/other.pyi +106 -106
- reflex/components/el/elements/scripts.pyi +46 -46
- reflex/components/el/elements/sectioning.pyi +226 -226
- reflex/components/el/elements/tables.pyi +151 -151
- reflex/components/el/elements/typography.pyi +226 -226
- reflex/components/gridjs/datatable.pyi +31 -31
- reflex/components/lucide/icon.pyi +46 -46
- reflex/components/markdown/markdown.pyi +16 -16
- reflex/components/moment/moment.pyi +17 -19
- reflex/components/next/base.pyi +16 -16
- reflex/components/next/image.pyi +18 -18
- reflex/components/next/link.pyi +16 -16
- reflex/components/next/video.pyi +16 -16
- reflex/components/plotly/plotly.pyi +34 -44
- reflex/components/radix/primitives/accordion.pyi +107 -107
- reflex/components/radix/primitives/base.pyi +31 -31
- reflex/components/radix/primitives/drawer.pyi +175 -183
- reflex/components/radix/primitives/form.pyi +160 -172
- reflex/components/radix/primitives/progress.pyi +76 -76
- reflex/components/radix/primitives/slider.pyi +78 -82
- reflex/components/radix/themes/base.pyi +121 -121
- reflex/components/radix/themes/color_mode.pyi +47 -49
- reflex/components/radix/themes/components/alert_dialog.pyi +110 -112
- reflex/components/radix/themes/components/aspect_ratio.pyi +16 -16
- reflex/components/radix/themes/components/avatar.pyi +16 -16
- reflex/components/radix/themes/components/badge.pyi +16 -16
- reflex/components/radix/themes/components/button.pyi +16 -16
- reflex/components/radix/themes/components/callout.pyi +76 -76
- reflex/components/radix/themes/components/card.pyi +16 -16
- reflex/components/radix/themes/components/checkbox.pyi +49 -55
- reflex/components/radix/themes/components/checkbox_cards.pyi +31 -31
- reflex/components/radix/themes/components/checkbox_group.pyi +31 -31
- reflex/components/radix/themes/components/context_menu.pyi +149 -155
- reflex/components/radix/themes/components/data_list.pyi +61 -61
- reflex/components/radix/themes/components/dialog.pyi +113 -117
- reflex/components/radix/themes/components/dropdown_menu.pyi +133 -137
- reflex/components/radix/themes/components/hover_card.pyi +63 -67
- reflex/components/radix/themes/components/icon_button.pyi +16 -16
- reflex/components/radix/themes/components/inset.pyi +16 -16
- reflex/components/radix/themes/components/popover.pyi +68 -70
- reflex/components/radix/themes/components/progress.pyi +16 -16
- reflex/components/radix/themes/components/radio.pyi +16 -16
- reflex/components/radix/themes/components/radio_cards.pyi +32 -34
- reflex/components/radix/themes/components/radio_group.pyi +62 -64
- reflex/components/radix/themes/components/scroll_area.pyi +16 -16
- reflex/components/radix/themes/components/segmented_control.pyi +32 -35
- reflex/components/radix/themes/components/select.py +1 -0
- reflex/components/radix/themes/components/select.pyi +145 -157
- reflex/components/radix/themes/components/separator.pyi +16 -16
- reflex/components/radix/themes/components/skeleton.py +3 -0
- reflex/components/radix/themes/components/skeleton.pyi +16 -16
- reflex/components/radix/themes/components/slider.pyi +22 -28
- reflex/components/radix/themes/components/spinner.pyi +16 -16
- reflex/components/radix/themes/components/switch.pyi +17 -19
- reflex/components/radix/themes/components/table.pyi +106 -106
- reflex/components/radix/themes/components/tabs.pyi +78 -82
- reflex/components/radix/themes/components/text_area.pyi +19 -33
- reflex/components/radix/themes/components/text_field.pyi +52 -80
- reflex/components/radix/themes/components/tooltip.py +3 -0
- reflex/components/radix/themes/components/tooltip.pyi +19 -21
- reflex/components/radix/themes/layout/base.pyi +16 -16
- reflex/components/radix/themes/layout/box.pyi +16 -16
- reflex/components/radix/themes/layout/center.pyi +16 -16
- reflex/components/radix/themes/layout/container.pyi +16 -16
- reflex/components/radix/themes/layout/flex.pyi +16 -16
- reflex/components/radix/themes/layout/grid.pyi +16 -16
- reflex/components/radix/themes/layout/list.pyi +76 -76
- reflex/components/radix/themes/layout/section.pyi +16 -16
- reflex/components/radix/themes/layout/spacer.pyi +16 -16
- reflex/components/radix/themes/layout/stack.pyi +46 -46
- reflex/components/radix/themes/typography/blockquote.pyi +16 -16
- reflex/components/radix/themes/typography/code.pyi +16 -16
- reflex/components/radix/themes/typography/heading.pyi +16 -16
- reflex/components/radix/themes/typography/link.pyi +16 -16
- reflex/components/radix/themes/typography/text.pyi +106 -106
- reflex/components/react_player/audio.pyi +33 -39
- reflex/components/react_player/react_player.pyi +32 -38
- reflex/components/react_player/video.pyi +33 -39
- reflex/components/recharts/cartesian.pyi +282 -282
- reflex/components/recharts/charts.pyi +164 -164
- reflex/components/recharts/general.pyi +92 -92
- reflex/components/recharts/polar.pyi +55 -55
- reflex/components/recharts/recharts.pyi +31 -31
- reflex/components/sonner/toast.pyi +16 -16
- reflex/components/suneditor/editor.pyi +24 -38
- reflex/custom_components/custom_components.py +10 -4
- reflex/event.py +89 -51
- reflex/experimental/layout.pyi +78 -82
- reflex/page.py +2 -2
- reflex/utils/exceptions.py +13 -0
- reflex/utils/format.py +1 -1
- reflex/utils/prerequisites.py +3 -3
- reflex/utils/pyi_generator.py +9 -8
- reflex/vars/base.py +10 -4
- {reflex-0.7.0a1.dist-info → reflex-0.7.0a3.dist-info}/METADATA +1 -1
- {reflex-0.7.0a1.dist-info → reflex-0.7.0a3.dist-info}/RECORD +129 -129
- {reflex-0.7.0a1.dist-info → reflex-0.7.0a3.dist-info}/LICENSE +0 -0
- {reflex-0.7.0a1.dist-info → reflex-0.7.0a3.dist-info}/WHEEL +0 -0
- {reflex-0.7.0a1.dist-info → reflex-0.7.0a3.dist-info}/entry_points.txt +0 -0
|
@@ -14,7 +14,7 @@ from typing import Optional, Tuple
|
|
|
14
14
|
import httpx
|
|
15
15
|
import tomlkit
|
|
16
16
|
import typer
|
|
17
|
-
from tomlkit.exceptions import TOMLKitError
|
|
17
|
+
from tomlkit.exceptions import NonExistentKey, TOMLKitError
|
|
18
18
|
|
|
19
19
|
from reflex import constants
|
|
20
20
|
from reflex.config import environment, get_config
|
|
@@ -533,7 +533,13 @@ def _get_version_to_publish() -> str:
|
|
|
533
533
|
Returns:
|
|
534
534
|
The version to publish.
|
|
535
535
|
"""
|
|
536
|
-
|
|
536
|
+
try:
|
|
537
|
+
return _get_package_config()["project"]["version"]
|
|
538
|
+
except NonExistentKey:
|
|
539
|
+
# Try to get the version from dynamic sources
|
|
540
|
+
import build.util
|
|
541
|
+
|
|
542
|
+
return build.util.project_wheel_metadata(".", isolated=True)["version"]
|
|
537
543
|
|
|
538
544
|
|
|
539
545
|
def _ensure_dist_dir(version_to_publish: str, build: bool):
|
|
@@ -756,7 +762,7 @@ def _min_validate_project_info():
|
|
|
756
762
|
)
|
|
757
763
|
raise typer.Exit(code=1)
|
|
758
764
|
|
|
759
|
-
if not project.get("version"):
|
|
765
|
+
if not project.get("version") and "version" not in project.get("dynamic", []):
|
|
760
766
|
console.error(
|
|
761
767
|
f"The project version is not found in {CustomComponents.PYPROJECT_TOML}"
|
|
762
768
|
)
|
|
@@ -772,7 +778,7 @@ def _validate_project_info():
|
|
|
772
778
|
pyproject_toml = _get_package_config()
|
|
773
779
|
project = pyproject_toml["project"]
|
|
774
780
|
console.print(
|
|
775
|
-
f"Double check the information before publishing: {project['name']} version {
|
|
781
|
+
f"Double check the information before publishing: {project['name']} version {_get_version_to_publish()}"
|
|
776
782
|
)
|
|
777
783
|
|
|
778
784
|
console.print("Update or enter to keep the current information.")
|
reflex/event.py
CHANGED
|
@@ -25,12 +25,12 @@ from typing import (
|
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
from typing_extensions import (
|
|
28
|
-
Concatenate,
|
|
29
|
-
ParamSpec,
|
|
30
28
|
Protocol,
|
|
31
29
|
TypeAliasType,
|
|
32
30
|
TypedDict,
|
|
33
31
|
TypeVar,
|
|
32
|
+
TypeVarTuple,
|
|
33
|
+
Unpack,
|
|
34
34
|
get_args,
|
|
35
35
|
get_origin,
|
|
36
36
|
)
|
|
@@ -1092,7 +1092,7 @@ def _callback_arg_spec(eval_result: Any):
|
|
|
1092
1092
|
|
|
1093
1093
|
def call_script(
|
|
1094
1094
|
javascript_code: str | Var[str],
|
|
1095
|
-
callback: EventType | None = None,
|
|
1095
|
+
callback: EventType[Any] | None = None,
|
|
1096
1096
|
) -> EventSpec:
|
|
1097
1097
|
"""Create an event handler that executes arbitrary javascript code.
|
|
1098
1098
|
|
|
@@ -1131,7 +1131,7 @@ def call_script(
|
|
|
1131
1131
|
|
|
1132
1132
|
def call_function(
|
|
1133
1133
|
javascript_code: str | Var,
|
|
1134
|
-
callback: EventType | None = None,
|
|
1134
|
+
callback: EventType[Any] | None = None,
|
|
1135
1135
|
) -> EventSpec:
|
|
1136
1136
|
"""Create an event handler that executes arbitrary javascript code.
|
|
1137
1137
|
|
|
@@ -1165,7 +1165,7 @@ def call_function(
|
|
|
1165
1165
|
|
|
1166
1166
|
def run_script(
|
|
1167
1167
|
javascript_code: str | Var,
|
|
1168
|
-
callback: EventType | None = None,
|
|
1168
|
+
callback: EventType[Any] | None = None,
|
|
1169
1169
|
) -> EventSpec:
|
|
1170
1170
|
"""Create an event handler that executes arbitrary javascript code.
|
|
1171
1171
|
|
|
@@ -1763,8 +1763,8 @@ class LiteralEventChainVar(ArgsFunctionOperationBuilder, LiteralVar, EventChainV
|
|
|
1763
1763
|
)
|
|
1764
1764
|
|
|
1765
1765
|
|
|
1766
|
-
P =
|
|
1767
|
-
Q =
|
|
1766
|
+
P = TypeVarTuple("P")
|
|
1767
|
+
Q = TypeVarTuple("Q")
|
|
1768
1768
|
T = TypeVar("T")
|
|
1769
1769
|
V = TypeVar("V")
|
|
1770
1770
|
V2 = TypeVar("V2")
|
|
@@ -1773,10 +1773,10 @@ V4 = TypeVar("V4")
|
|
|
1773
1773
|
V5 = TypeVar("V5")
|
|
1774
1774
|
|
|
1775
1775
|
|
|
1776
|
-
class EventCallback(Generic[P
|
|
1776
|
+
class EventCallback(Generic[Unpack[P]]):
|
|
1777
1777
|
"""A descriptor that wraps a function to be used as an event."""
|
|
1778
1778
|
|
|
1779
|
-
def __init__(self, func: Callable[
|
|
1779
|
+
def __init__(self, func: Callable[[Any, Unpack[P]], Any]):
|
|
1780
1780
|
"""Initialize the descriptor with the function to be wrapped.
|
|
1781
1781
|
|
|
1782
1782
|
Args:
|
|
@@ -1804,37 +1804,37 @@ class EventCallback(Generic[P, T]):
|
|
|
1804
1804
|
|
|
1805
1805
|
@overload
|
|
1806
1806
|
def __call__(
|
|
1807
|
-
self: EventCallback[Q
|
|
1808
|
-
) -> EventCallback[Q
|
|
1807
|
+
self: EventCallback[Unpack[Q]],
|
|
1808
|
+
) -> EventCallback[Unpack[Q]]: ...
|
|
1809
1809
|
|
|
1810
1810
|
@overload
|
|
1811
1811
|
def __call__(
|
|
1812
|
-
self: EventCallback[
|
|
1813
|
-
) -> EventCallback[Q
|
|
1812
|
+
self: EventCallback[V, Unpack[Q]], value: V | Var[V]
|
|
1813
|
+
) -> EventCallback[Unpack[Q]]: ...
|
|
1814
1814
|
|
|
1815
1815
|
@overload
|
|
1816
1816
|
def __call__(
|
|
1817
|
-
self: EventCallback[
|
|
1817
|
+
self: EventCallback[V, V2, Unpack[Q]],
|
|
1818
1818
|
value: V | Var[V],
|
|
1819
1819
|
value2: V2 | Var[V2],
|
|
1820
|
-
) -> EventCallback[Q
|
|
1820
|
+
) -> EventCallback[Unpack[Q]]: ...
|
|
1821
1821
|
|
|
1822
1822
|
@overload
|
|
1823
1823
|
def __call__(
|
|
1824
|
-
self: EventCallback[
|
|
1824
|
+
self: EventCallback[V, V2, V3, Unpack[Q]],
|
|
1825
1825
|
value: V | Var[V],
|
|
1826
1826
|
value2: V2 | Var[V2],
|
|
1827
1827
|
value3: V3 | Var[V3],
|
|
1828
|
-
) -> EventCallback[Q
|
|
1828
|
+
) -> EventCallback[Unpack[Q]]: ...
|
|
1829
1829
|
|
|
1830
1830
|
@overload
|
|
1831
1831
|
def __call__(
|
|
1832
|
-
self: EventCallback[
|
|
1832
|
+
self: EventCallback[V, V2, V3, V4, Unpack[Q]],
|
|
1833
1833
|
value: V | Var[V],
|
|
1834
1834
|
value2: V2 | Var[V2],
|
|
1835
1835
|
value3: V3 | Var[V3],
|
|
1836
1836
|
value4: V4 | Var[V4],
|
|
1837
|
-
) -> EventCallback[Q
|
|
1837
|
+
) -> EventCallback[Unpack[Q]]: ...
|
|
1838
1838
|
|
|
1839
1839
|
def __call__(self, *values) -> EventCallback: # pyright: ignore [reportInconsistentOverload]
|
|
1840
1840
|
"""Call the function with the values.
|
|
@@ -1845,15 +1845,15 @@ class EventCallback(Generic[P, T]):
|
|
|
1845
1845
|
Returns:
|
|
1846
1846
|
The function with the values.
|
|
1847
1847
|
"""
|
|
1848
|
-
return self.func(*values) # pyright: ignore [
|
|
1848
|
+
return self.func(*values) # pyright: ignore [reportArgumentType]
|
|
1849
1849
|
|
|
1850
1850
|
@overload
|
|
1851
1851
|
def __get__(
|
|
1852
|
-
self: EventCallback[P
|
|
1853
|
-
) -> EventCallback[P
|
|
1852
|
+
self: EventCallback[Unpack[P]], instance: None, owner: Any
|
|
1853
|
+
) -> EventCallback[Unpack[P]]: ...
|
|
1854
1854
|
|
|
1855
1855
|
@overload
|
|
1856
|
-
def __get__(self, instance: Any, owner: Any) -> Callable[P
|
|
1856
|
+
def __get__(self, instance: Any, owner: Any) -> Callable[[Unpack[P]]]: ...
|
|
1857
1857
|
|
|
1858
1858
|
def __get__(self, instance: Any, owner: Any) -> Callable:
|
|
1859
1859
|
"""Get the function with the instance bound to it.
|
|
@@ -1871,33 +1871,69 @@ class EventCallback(Generic[P, T]):
|
|
|
1871
1871
|
return partial(self.func, instance)
|
|
1872
1872
|
|
|
1873
1873
|
|
|
1874
|
-
|
|
1874
|
+
class LambdaEventCallback(Protocol[Unpack[P]]):
|
|
1875
|
+
"""A protocol for a lambda event callback."""
|
|
1875
1876
|
|
|
1876
|
-
|
|
1877
|
-
|
|
1877
|
+
@overload
|
|
1878
|
+
def __call__(self: LambdaEventCallback[()]) -> Any: ...
|
|
1878
1879
|
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1880
|
+
@overload
|
|
1881
|
+
def __call__(self: LambdaEventCallback[V], value: Var[V], /) -> Any: ...
|
|
1882
|
+
|
|
1883
|
+
@overload
|
|
1884
|
+
def __call__(
|
|
1885
|
+
self: LambdaEventCallback[V, V2], value: Var[V], value2: Var[V2], /
|
|
1886
|
+
) -> Any: ...
|
|
1887
|
+
|
|
1888
|
+
@overload
|
|
1889
|
+
def __call__(
|
|
1890
|
+
self: LambdaEventCallback[V, V2, V3],
|
|
1891
|
+
value: Var[V],
|
|
1892
|
+
value2: Var[V2],
|
|
1893
|
+
value3: Var[V3],
|
|
1894
|
+
/,
|
|
1895
|
+
) -> Any: ...
|
|
1896
|
+
|
|
1897
|
+
def __call__(self, *args: Var) -> Any:
|
|
1898
|
+
"""Call the lambda with the args.
|
|
1899
|
+
|
|
1900
|
+
Args:
|
|
1901
|
+
*args: The args to call the lambda with.
|
|
1902
|
+
"""
|
|
1903
|
+
|
|
1904
|
+
|
|
1905
|
+
ARGS = TypeVarTuple("ARGS")
|
|
1906
|
+
|
|
1907
|
+
|
|
1908
|
+
LAMBDA_OR_STATE = TypeAliasType(
|
|
1909
|
+
"LAMBDA_OR_STATE",
|
|
1910
|
+
LambdaEventCallback[Unpack[ARGS]] | EventCallback[Unpack[ARGS]],
|
|
1911
|
+
type_params=(ARGS,),
|
|
1912
|
+
)
|
|
1913
|
+
|
|
1914
|
+
ItemOrList = V | List[V]
|
|
1915
|
+
|
|
1916
|
+
BASIC_EVENT_TYPES = TypeAliasType(
|
|
1917
|
+
"BASIC_EVENT_TYPES", EventSpec | EventHandler | Var[Any], type_params=()
|
|
1918
|
+
)
|
|
1919
|
+
|
|
1920
|
+
IndividualEventType = TypeAliasType(
|
|
1921
|
+
"IndividualEventType",
|
|
1922
|
+
LAMBDA_OR_STATE[Unpack[ARGS]] | BASIC_EVENT_TYPES,
|
|
1923
|
+
type_params=(ARGS,),
|
|
1924
|
+
)
|
|
1882
1925
|
|
|
1883
|
-
|
|
1884
|
-
"
|
|
1885
|
-
Callable[Concatenate[BASE_STATE, G], Any],
|
|
1886
|
-
type_params=(G, BASE_STATE),
|
|
1926
|
+
EventType = TypeAliasType(
|
|
1927
|
+
"EventType", ItemOrList[IndividualEventType[Unpack[ARGS]]], type_params=(ARGS,)
|
|
1887
1928
|
)
|
|
1888
1929
|
|
|
1889
|
-
IndividualEventType = Union[
|
|
1890
|
-
EventSpec,
|
|
1891
|
-
EventHandler,
|
|
1892
|
-
Callable[G, Any],
|
|
1893
|
-
StateCallable[G, BASE_STATE],
|
|
1894
|
-
EventCallback[G, Any],
|
|
1895
|
-
Var[Any],
|
|
1896
|
-
]
|
|
1897
1930
|
|
|
1898
|
-
|
|
1931
|
+
if TYPE_CHECKING:
|
|
1932
|
+
from reflex.state import BaseState
|
|
1899
1933
|
|
|
1900
|
-
|
|
1934
|
+
BASE_STATE = TypeVar("BASE_STATE", bound=BaseState)
|
|
1935
|
+
else:
|
|
1936
|
+
BASE_STATE = TypeVar("BASE_STATE")
|
|
1901
1937
|
|
|
1902
1938
|
|
|
1903
1939
|
class EventNamespace(types.SimpleNamespace):
|
|
@@ -1919,24 +1955,26 @@ class EventNamespace(types.SimpleNamespace):
|
|
|
1919
1955
|
@staticmethod
|
|
1920
1956
|
def __call__(
|
|
1921
1957
|
func: None = None, *, background: bool | None = None
|
|
1922
|
-
) -> Callable[
|
|
1958
|
+
) -> Callable[
|
|
1959
|
+
[Callable[[BASE_STATE, Unpack[P]], Any]], EventCallback[Unpack[P]] # pyright: ignore [reportInvalidTypeVarUse]
|
|
1960
|
+
]: ...
|
|
1923
1961
|
|
|
1924
1962
|
@overload
|
|
1925
1963
|
@staticmethod
|
|
1926
1964
|
def __call__(
|
|
1927
|
-
func: Callable[
|
|
1965
|
+
func: Callable[[BASE_STATE, Unpack[P]], Any],
|
|
1928
1966
|
*,
|
|
1929
1967
|
background: bool | None = None,
|
|
1930
|
-
) -> EventCallback[P
|
|
1968
|
+
) -> EventCallback[Unpack[P]]: ...
|
|
1931
1969
|
|
|
1932
1970
|
@staticmethod
|
|
1933
1971
|
def __call__(
|
|
1934
|
-
func: Callable[
|
|
1972
|
+
func: Callable[[BASE_STATE, Unpack[P]], Any] | None = None,
|
|
1935
1973
|
*,
|
|
1936
1974
|
background: bool | None = None,
|
|
1937
1975
|
) -> Union[
|
|
1938
|
-
EventCallback[P
|
|
1939
|
-
Callable[[Callable[
|
|
1976
|
+
EventCallback[Unpack[P]],
|
|
1977
|
+
Callable[[Callable[[BASE_STATE, Unpack[P]], Any]], EventCallback[Unpack[P]]],
|
|
1940
1978
|
]:
|
|
1941
1979
|
"""Wrap a function to be used as an event.
|
|
1942
1980
|
|
|
@@ -1952,8 +1990,8 @@ class EventNamespace(types.SimpleNamespace):
|
|
|
1952
1990
|
"""
|
|
1953
1991
|
|
|
1954
1992
|
def wrapper(
|
|
1955
|
-
func: Callable[
|
|
1956
|
-
) -> EventCallback[P
|
|
1993
|
+
func: Callable[[BASE_STATE, Unpack[P]], T],
|
|
1994
|
+
) -> EventCallback[Unpack[P]]:
|
|
1957
1995
|
if background is True:
|
|
1958
1996
|
if not inspect.iscoroutinefunction(
|
|
1959
1997
|
func
|
reflex/experimental/layout.pyi
CHANGED
|
@@ -10,7 +10,7 @@ from reflex.components.base.fragment import Fragment
|
|
|
10
10
|
from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
|
|
11
11
|
from reflex.components.radix.primitives.drawer import DrawerRoot
|
|
12
12
|
from reflex.components.radix.themes.layout.box import Box
|
|
13
|
-
from reflex.event import
|
|
13
|
+
from reflex.event import EventType
|
|
14
14
|
from reflex.state import ComponentState
|
|
15
15
|
from reflex.style import Style
|
|
16
16
|
from reflex.vars.base import Var
|
|
@@ -51,21 +51,21 @@ class Sidebar(Box, MemoizationLeaf):
|
|
|
51
51
|
class_name: Optional[Any] = None,
|
|
52
52
|
autofocus: Optional[bool] = None,
|
|
53
53
|
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
|
|
54
|
-
on_blur: Optional[EventType[
|
|
55
|
-
on_click: Optional[EventType[
|
|
56
|
-
on_context_menu: Optional[EventType[
|
|
57
|
-
on_double_click: Optional[EventType[
|
|
58
|
-
on_focus: Optional[EventType[
|
|
59
|
-
on_mount: Optional[EventType[
|
|
60
|
-
on_mouse_down: Optional[EventType[
|
|
61
|
-
on_mouse_enter: Optional[EventType[
|
|
62
|
-
on_mouse_leave: Optional[EventType[
|
|
63
|
-
on_mouse_move: Optional[EventType[
|
|
64
|
-
on_mouse_out: Optional[EventType[
|
|
65
|
-
on_mouse_over: Optional[EventType[
|
|
66
|
-
on_mouse_up: Optional[EventType[
|
|
67
|
-
on_scroll: Optional[EventType[
|
|
68
|
-
on_unmount: Optional[EventType[
|
|
54
|
+
on_blur: Optional[EventType[()]] = None,
|
|
55
|
+
on_click: Optional[EventType[()]] = None,
|
|
56
|
+
on_context_menu: Optional[EventType[()]] = None,
|
|
57
|
+
on_double_click: Optional[EventType[()]] = None,
|
|
58
|
+
on_focus: Optional[EventType[()]] = None,
|
|
59
|
+
on_mount: Optional[EventType[()]] = None,
|
|
60
|
+
on_mouse_down: Optional[EventType[()]] = None,
|
|
61
|
+
on_mouse_enter: Optional[EventType[()]] = None,
|
|
62
|
+
on_mouse_leave: Optional[EventType[()]] = None,
|
|
63
|
+
on_mouse_move: Optional[EventType[()]] = None,
|
|
64
|
+
on_mouse_out: Optional[EventType[()]] = None,
|
|
65
|
+
on_mouse_over: Optional[EventType[()]] = None,
|
|
66
|
+
on_mouse_up: Optional[EventType[()]] = None,
|
|
67
|
+
on_scroll: Optional[EventType[()]] = None,
|
|
68
|
+
on_unmount: Optional[EventType[()]] = None,
|
|
69
69
|
**props,
|
|
70
70
|
) -> "Sidebar":
|
|
71
71
|
"""Create the sidebar component.
|
|
@@ -119,27 +119,23 @@ class DrawerSidebar(DrawerRoot):
|
|
|
119
119
|
class_name: Optional[Any] = None,
|
|
120
120
|
autofocus: Optional[bool] = None,
|
|
121
121
|
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
|
|
122
|
-
on_animation_end: Optional[
|
|
123
|
-
|
|
124
|
-
] = None,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
|
|
140
|
-
] = None,
|
|
141
|
-
on_scroll: Optional[EventType[[], BASE_STATE]] = None,
|
|
142
|
-
on_unmount: Optional[EventType[[], BASE_STATE]] = None,
|
|
122
|
+
on_animation_end: Optional[Union[EventType[()], EventType[bool]]] = None,
|
|
123
|
+
on_blur: Optional[EventType[()]] = None,
|
|
124
|
+
on_click: Optional[EventType[()]] = None,
|
|
125
|
+
on_context_menu: Optional[EventType[()]] = None,
|
|
126
|
+
on_double_click: Optional[EventType[()]] = None,
|
|
127
|
+
on_focus: Optional[EventType[()]] = None,
|
|
128
|
+
on_mount: Optional[EventType[()]] = None,
|
|
129
|
+
on_mouse_down: Optional[EventType[()]] = None,
|
|
130
|
+
on_mouse_enter: Optional[EventType[()]] = None,
|
|
131
|
+
on_mouse_leave: Optional[EventType[()]] = None,
|
|
132
|
+
on_mouse_move: Optional[EventType[()]] = None,
|
|
133
|
+
on_mouse_out: Optional[EventType[()]] = None,
|
|
134
|
+
on_mouse_over: Optional[EventType[()]] = None,
|
|
135
|
+
on_mouse_up: Optional[EventType[()]] = None,
|
|
136
|
+
on_open_change: Optional[Union[EventType[()], EventType[bool]]] = None,
|
|
137
|
+
on_scroll: Optional[EventType[()]] = None,
|
|
138
|
+
on_unmount: Optional[EventType[()]] = None,
|
|
143
139
|
**props,
|
|
144
140
|
) -> "DrawerSidebar":
|
|
145
141
|
"""Create the sidebar component.
|
|
@@ -173,21 +169,21 @@ class SidebarTrigger(Fragment):
|
|
|
173
169
|
class_name: Optional[Any] = None,
|
|
174
170
|
autofocus: Optional[bool] = None,
|
|
175
171
|
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
|
|
176
|
-
on_blur: Optional[EventType[
|
|
177
|
-
on_click: Optional[EventType[
|
|
178
|
-
on_context_menu: Optional[EventType[
|
|
179
|
-
on_double_click: Optional[EventType[
|
|
180
|
-
on_focus: Optional[EventType[
|
|
181
|
-
on_mount: Optional[EventType[
|
|
182
|
-
on_mouse_down: Optional[EventType[
|
|
183
|
-
on_mouse_enter: Optional[EventType[
|
|
184
|
-
on_mouse_leave: Optional[EventType[
|
|
185
|
-
on_mouse_move: Optional[EventType[
|
|
186
|
-
on_mouse_out: Optional[EventType[
|
|
187
|
-
on_mouse_over: Optional[EventType[
|
|
188
|
-
on_mouse_up: Optional[EventType[
|
|
189
|
-
on_scroll: Optional[EventType[
|
|
190
|
-
on_unmount: Optional[EventType[
|
|
172
|
+
on_blur: Optional[EventType[()]] = None,
|
|
173
|
+
on_click: Optional[EventType[()]] = None,
|
|
174
|
+
on_context_menu: Optional[EventType[()]] = None,
|
|
175
|
+
on_double_click: Optional[EventType[()]] = None,
|
|
176
|
+
on_focus: Optional[EventType[()]] = None,
|
|
177
|
+
on_mount: Optional[EventType[()]] = None,
|
|
178
|
+
on_mouse_down: Optional[EventType[()]] = None,
|
|
179
|
+
on_mouse_enter: Optional[EventType[()]] = None,
|
|
180
|
+
on_mouse_leave: Optional[EventType[()]] = None,
|
|
181
|
+
on_mouse_move: Optional[EventType[()]] = None,
|
|
182
|
+
on_mouse_out: Optional[EventType[()]] = None,
|
|
183
|
+
on_mouse_over: Optional[EventType[()]] = None,
|
|
184
|
+
on_mouse_up: Optional[EventType[()]] = None,
|
|
185
|
+
on_scroll: Optional[EventType[()]] = None,
|
|
186
|
+
on_unmount: Optional[EventType[()]] = None,
|
|
191
187
|
**props,
|
|
192
188
|
) -> "SidebarTrigger":
|
|
193
189
|
"""Create the sidebar trigger component.
|
|
@@ -238,21 +234,21 @@ class Layout(Box):
|
|
|
238
234
|
class_name: Optional[Any] = None,
|
|
239
235
|
autofocus: Optional[bool] = None,
|
|
240
236
|
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
|
|
241
|
-
on_blur: Optional[EventType[
|
|
242
|
-
on_click: Optional[EventType[
|
|
243
|
-
on_context_menu: Optional[EventType[
|
|
244
|
-
on_double_click: Optional[EventType[
|
|
245
|
-
on_focus: Optional[EventType[
|
|
246
|
-
on_mount: Optional[EventType[
|
|
247
|
-
on_mouse_down: Optional[EventType[
|
|
248
|
-
on_mouse_enter: Optional[EventType[
|
|
249
|
-
on_mouse_leave: Optional[EventType[
|
|
250
|
-
on_mouse_move: Optional[EventType[
|
|
251
|
-
on_mouse_out: Optional[EventType[
|
|
252
|
-
on_mouse_over: Optional[EventType[
|
|
253
|
-
on_mouse_up: Optional[EventType[
|
|
254
|
-
on_scroll: Optional[EventType[
|
|
255
|
-
on_unmount: Optional[EventType[
|
|
237
|
+
on_blur: Optional[EventType[()]] = None,
|
|
238
|
+
on_click: Optional[EventType[()]] = None,
|
|
239
|
+
on_context_menu: Optional[EventType[()]] = None,
|
|
240
|
+
on_double_click: Optional[EventType[()]] = None,
|
|
241
|
+
on_focus: Optional[EventType[()]] = None,
|
|
242
|
+
on_mount: Optional[EventType[()]] = None,
|
|
243
|
+
on_mouse_down: Optional[EventType[()]] = None,
|
|
244
|
+
on_mouse_enter: Optional[EventType[()]] = None,
|
|
245
|
+
on_mouse_leave: Optional[EventType[()]] = None,
|
|
246
|
+
on_mouse_move: Optional[EventType[()]] = None,
|
|
247
|
+
on_mouse_out: Optional[EventType[()]] = None,
|
|
248
|
+
on_mouse_over: Optional[EventType[()]] = None,
|
|
249
|
+
on_mouse_up: Optional[EventType[()]] = None,
|
|
250
|
+
on_scroll: Optional[EventType[()]] = None,
|
|
251
|
+
on_unmount: Optional[EventType[()]] = None,
|
|
256
252
|
**props,
|
|
257
253
|
) -> "Layout":
|
|
258
254
|
"""Create the layout component.
|
|
@@ -306,21 +302,21 @@ class LayoutNamespace(ComponentNamespace):
|
|
|
306
302
|
class_name: Optional[Any] = None,
|
|
307
303
|
autofocus: Optional[bool] = None,
|
|
308
304
|
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
|
|
309
|
-
on_blur: Optional[EventType[
|
|
310
|
-
on_click: Optional[EventType[
|
|
311
|
-
on_context_menu: Optional[EventType[
|
|
312
|
-
on_double_click: Optional[EventType[
|
|
313
|
-
on_focus: Optional[EventType[
|
|
314
|
-
on_mount: Optional[EventType[
|
|
315
|
-
on_mouse_down: Optional[EventType[
|
|
316
|
-
on_mouse_enter: Optional[EventType[
|
|
317
|
-
on_mouse_leave: Optional[EventType[
|
|
318
|
-
on_mouse_move: Optional[EventType[
|
|
319
|
-
on_mouse_out: Optional[EventType[
|
|
320
|
-
on_mouse_over: Optional[EventType[
|
|
321
|
-
on_mouse_up: Optional[EventType[
|
|
322
|
-
on_scroll: Optional[EventType[
|
|
323
|
-
on_unmount: Optional[EventType[
|
|
305
|
+
on_blur: Optional[EventType[()]] = None,
|
|
306
|
+
on_click: Optional[EventType[()]] = None,
|
|
307
|
+
on_context_menu: Optional[EventType[()]] = None,
|
|
308
|
+
on_double_click: Optional[EventType[()]] = None,
|
|
309
|
+
on_focus: Optional[EventType[()]] = None,
|
|
310
|
+
on_mount: Optional[EventType[()]] = None,
|
|
311
|
+
on_mouse_down: Optional[EventType[()]] = None,
|
|
312
|
+
on_mouse_enter: Optional[EventType[()]] = None,
|
|
313
|
+
on_mouse_leave: Optional[EventType[()]] = None,
|
|
314
|
+
on_mouse_move: Optional[EventType[()]] = None,
|
|
315
|
+
on_mouse_out: Optional[EventType[()]] = None,
|
|
316
|
+
on_mouse_over: Optional[EventType[()]] = None,
|
|
317
|
+
on_mouse_up: Optional[EventType[()]] = None,
|
|
318
|
+
on_scroll: Optional[EventType[()]] = None,
|
|
319
|
+
on_unmount: Optional[EventType[()]] = None,
|
|
324
320
|
**props,
|
|
325
321
|
) -> "Layout":
|
|
326
322
|
"""Create the layout component.
|
reflex/page.py
CHANGED
|
@@ -6,7 +6,7 @@ from collections import defaultdict
|
|
|
6
6
|
from typing import Any, Callable, Dict, List
|
|
7
7
|
|
|
8
8
|
from reflex.config import get_config
|
|
9
|
-
from reflex.event import
|
|
9
|
+
from reflex.event import EventType
|
|
10
10
|
|
|
11
11
|
DECORATED_PAGES: Dict[str, List] = defaultdict(list)
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ def page(
|
|
|
18
18
|
description: str | None = None,
|
|
19
19
|
meta: list[Any] | None = None,
|
|
20
20
|
script_tags: list[Any] | None = None,
|
|
21
|
-
on_load: EventType[
|
|
21
|
+
on_load: EventType[()] | None = None,
|
|
22
22
|
):
|
|
23
23
|
"""Decorate a function as a page.
|
|
24
24
|
|
reflex/utils/exceptions.py
CHANGED
|
@@ -91,6 +91,19 @@ class UntypedComputedVarError(ReflexError, TypeError):
|
|
|
91
91
|
super().__init__(f"Computed var '{var_name}' must have a type annotation.")
|
|
92
92
|
|
|
93
93
|
|
|
94
|
+
class ComputedVarSignatureError(ReflexError, TypeError):
|
|
95
|
+
"""Custom TypeError for computed var signature errors."""
|
|
96
|
+
|
|
97
|
+
def __init__(self, var_name: str, signature: str):
|
|
98
|
+
"""Initialize the ComputedVarSignatureError.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
var_name: The name of the var.
|
|
102
|
+
signature: The invalid signature.
|
|
103
|
+
"""
|
|
104
|
+
super().__init__(f"Computed var `{var_name}{signature}` cannot take arguments.")
|
|
105
|
+
|
|
106
|
+
|
|
94
107
|
class MissingAnnotationError(ReflexError, TypeError):
|
|
95
108
|
"""Custom TypeError for missing annotations."""
|
|
96
109
|
|
reflex/utils/format.py
CHANGED
|
@@ -502,7 +502,7 @@ if TYPE_CHECKING:
|
|
|
502
502
|
|
|
503
503
|
|
|
504
504
|
def format_queue_events(
|
|
505
|
-
events: EventType | None = None,
|
|
505
|
+
events: EventType[Any] | None = None,
|
|
506
506
|
args_spec: Optional[ArgsSpec] = None,
|
|
507
507
|
) -> Var[EventChain]:
|
|
508
508
|
"""Format a list of event handler / event spec as a javascript callback.
|
reflex/utils/prerequisites.py
CHANGED
|
@@ -64,7 +64,7 @@ class Template:
|
|
|
64
64
|
name: str
|
|
65
65
|
description: str
|
|
66
66
|
code_url: str
|
|
67
|
-
demo_url: str
|
|
67
|
+
demo_url: str | None = None
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
@dataclasses.dataclass(frozen=True)
|
|
@@ -1293,7 +1293,7 @@ def validate_bun():
|
|
|
1293
1293
|
"""
|
|
1294
1294
|
bun_path = path_ops.get_bun_path()
|
|
1295
1295
|
|
|
1296
|
-
if bun_path and bun_path.samefile(constants.Bun.DEFAULT_PATH):
|
|
1296
|
+
if bun_path and not bun_path.samefile(constants.Bun.DEFAULT_PATH):
|
|
1297
1297
|
console.info(f"Using custom Bun path: {bun_path}")
|
|
1298
1298
|
bun_version = get_bun_version()
|
|
1299
1299
|
if not bun_version:
|
|
@@ -1461,7 +1461,7 @@ def prompt_for_template_options(templates: list[Template]) -> str:
|
|
|
1461
1461
|
# Show the user the URLs of each template to preview.
|
|
1462
1462
|
console.print("\nGet started with a template:")
|
|
1463
1463
|
|
|
1464
|
-
def format_demo_url_str(url: str) -> str:
|
|
1464
|
+
def format_demo_url_str(url: str | None) -> str:
|
|
1465
1465
|
return f" ({url})" if url else ""
|
|
1466
1466
|
|
|
1467
1467
|
# Prompt the user to select a template.
|
reflex/utils/pyi_generator.py
CHANGED
|
@@ -75,7 +75,6 @@ DEFAULT_IMPORTS = {
|
|
|
75
75
|
"EventHandler",
|
|
76
76
|
"EventSpec",
|
|
77
77
|
"EventType",
|
|
78
|
-
"BASE_STATE",
|
|
79
78
|
"KeyInputInfo",
|
|
80
79
|
],
|
|
81
80
|
"reflex.style": ["Style"],
|
|
@@ -502,7 +501,7 @@ def _generate_component_create_functiondef(
|
|
|
502
501
|
|
|
503
502
|
def figure_out_return_type(annotation: Any):
|
|
504
503
|
if inspect.isclass(annotation) and issubclass(annotation, inspect._empty):
|
|
505
|
-
return ast.Name(id="EventType[
|
|
504
|
+
return ast.Name(id="EventType[Any]")
|
|
506
505
|
|
|
507
506
|
if not isinstance(annotation, str) and get_origin(annotation) is tuple:
|
|
508
507
|
arguments = get_args(annotation)
|
|
@@ -518,8 +517,10 @@ def _generate_component_create_functiondef(
|
|
|
518
517
|
# Get all prefixes of the type arguments
|
|
519
518
|
all_count_args_type = [
|
|
520
519
|
ast.Name(
|
|
521
|
-
f"EventType[
|
|
520
|
+
f"EventType[{', '.join([ast.unparse(arg) for arg in type_args[:i]])}]"
|
|
522
521
|
)
|
|
522
|
+
if i > 0
|
|
523
|
+
else ast.Name("EventType[()]")
|
|
523
524
|
for i in range(len(type_args) + 1)
|
|
524
525
|
]
|
|
525
526
|
|
|
@@ -532,7 +533,7 @@ def _generate_component_create_functiondef(
|
|
|
532
533
|
inside_of_tuple = annotation.removeprefix("Tuple[").removesuffix("]")
|
|
533
534
|
|
|
534
535
|
if inside_of_tuple == "()":
|
|
535
|
-
return ast.Name(id="EventType[
|
|
536
|
+
return ast.Name(id="EventType[()]")
|
|
536
537
|
|
|
537
538
|
arguments = [""]
|
|
538
539
|
|
|
@@ -559,16 +560,16 @@ def _generate_component_create_functiondef(
|
|
|
559
560
|
]
|
|
560
561
|
|
|
561
562
|
all_count_args_type = [
|
|
562
|
-
ast.Name(
|
|
563
|
-
|
|
564
|
-
)
|
|
563
|
+
ast.Name(f"EventType[{', '.join(arguments_without_var[:i])}]")
|
|
564
|
+
if i > 0
|
|
565
|
+
else ast.Name("EventType[()]")
|
|
565
566
|
for i in range(len(arguments) + 1)
|
|
566
567
|
]
|
|
567
568
|
|
|
568
569
|
return ast.Name(
|
|
569
570
|
id=f"Union[{', '.join(map(ast.unparse, all_count_args_type))}]"
|
|
570
571
|
)
|
|
571
|
-
return ast.Name(id="EventType[
|
|
572
|
+
return ast.Name(id="EventType[Any]")
|
|
572
573
|
|
|
573
574
|
event_triggers = clz().get_event_triggers()
|
|
574
575
|
|