Compare commits

...

8 Commits

Author SHA1 Message Date
Masen Furer
3e9f346a54
bump to final 0.6.5 2024-11-12 13:47:13 -08:00
Masen Furer
593ec2342f
Temporarily downpin @radix-ui/themes <3.1.5 (#4370)
* Temporarily downpin @radix-ui/themes <3.1.5

A visual/style regression was introduced in @radix-ui/themes 3.1.5
as described in radix-ui/themes#627 which reflex needs to avoid.

* Get expected radix library version from component
2024-11-12 13:47:04 -08:00
Masen Furer
1f7e7aff15
bump to 0.6.5a3 2024-11-12 09:38:39 -08:00
Masen Furer
d6e59b9b51
Only pass Model.__fields__ when casting event args (#4356)
Attempting to initialize relationship fields in a sqlmodel model throws an
error, so only pass defined pydantic __fields__ if the type is a Model.
2024-11-12 09:38:21 -08:00
Masen Furer
cc337a8e52
Bump reflex-hosting-cli dep to 0.1.15 for v2 (#4355) 2024-11-12 09:38:20 -08:00
Masen Furer
e0911c5e68
bump to 0.6.5a2 2024-11-11 11:14:27 -08:00
Khaleel Al-Adhami
4afea2d338
fix upload argspec being missing (#4335) 2024-11-11 11:14:17 -08:00
Masen Furer
103069a188
bump to 0.6.5a1 2024-11-07 21:04:25 -08:00
7 changed files with 87 additions and 18 deletions

6
poetry.lock generated
View File

@ -1350,8 +1350,8 @@ files = [
[package.dependencies]
numpy = [
{version = ">=1.26.0", markers = "python_version >= \"3.12\""},
{version = ">=1.23.2", markers = "python_version == \"3.11\""},
{version = ">=1.26.0", markers = "python_version >= \"3.12\""},
{version = ">=1.22.4", markers = "python_version < \"3.11\""},
]
python-dateutil = ">=2.8.2"
@ -1669,8 +1669,8 @@ files = [
annotated-types = ">=0.6.0"
pydantic-core = "2.23.4"
typing-extensions = [
{version = ">=4.12.2", markers = "python_version >= \"3.13\""},
{version = ">=4.6.1", markers = "python_version < \"3.13\""},
{version = ">=4.12.2", markers = "python_version >= \"3.13\""},
]
[package.extras]
@ -3050,4 +3050,4 @@ type = ["pytest-mypy"]
[metadata]
lock-version = "2.0"
python-versions = "^3.9"
content-hash = "593a52e9f54e95b50074f1bc4b7cdbabe4fab325051c72b23219268c0c9aa3ba"
content-hash = "937f0cadb1a4566117dad8d0be6018ad1a8fe9aeb19c499d2a010d36ef391ee1"

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "reflex"
version = "0.6.5dev1"
version = "0.6.5"
description = "Web apps in pure Python."
license = "Apache-2.0"
authors = [
@ -49,7 +49,7 @@ wrapt = [
{version = ">=1.11.0,<2.0", python = "<3.11"},
]
packaging = ">=23.1,<25.0"
reflex-hosting-cli = ">=0.1.5,<2.0"
reflex-hosting-cli = ">=0.1.15,<2.0"
charset-normalizer = ">=3.3.2,<4.0"
wheel = ">=0.42.0,<1.0"
build = ">=1.0.3,<2.0"

View File

@ -5,6 +5,7 @@ from __future__ import annotations
from pathlib import Path
from typing import Any, Callable, ClassVar, Dict, List, Optional, Tuple
from reflex.components.base.fragment import Fragment
from reflex.components.component import (
Component,
ComponentNamespace,
@ -181,6 +182,13 @@ class UploadFilesProvider(Component):
tag = "UploadFilesProvider"
class GhostUpload(Fragment):
"""A ghost upload component."""
# Fired when files are dropped.
on_drop: EventHandler[_on_drop_spec]
class Upload(MemoizationLeaf):
"""A file upload component."""
@ -276,8 +284,8 @@ class Upload(MemoizationLeaf):
root_props_unique_name = get_unique_variable_name()
event_var, callback_str = StatefulComponent._get_memoized_event_triggers(
Box.create(on_click=upload_props["on_drop"]) # type: ignore
)["on_click"]
GhostUpload.create(on_drop=upload_props["on_drop"])
)["on_drop"]
upload_props["on_drop"] = event_var

View File

@ -6,6 +6,7 @@
from pathlib import Path
from typing import Any, ClassVar, Dict, List, Optional, Union, overload
from reflex.components.base.fragment import Fragment
from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
from reflex.constants import Dirs
from reflex.event import BASE_STATE, CallableEventSpec, EventSpec, EventType
@ -84,6 +85,56 @@ class UploadFilesProvider(Component):
"""
...
class GhostUpload(Fragment):
@overload
@classmethod
def create( # type: ignore
cls,
*children,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
on_blur: Optional[EventType[[], BASE_STATE]] = None,
on_click: Optional[EventType[[], BASE_STATE]] = None,
on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
on_double_click: Optional[EventType[[], BASE_STATE]] = None,
on_drop: Optional[
Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]]
] = None,
on_focus: Optional[EventType[[], BASE_STATE]] = None,
on_mount: Optional[EventType[[], BASE_STATE]] = None,
on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
on_scroll: Optional[EventType[[], BASE_STATE]] = None,
on_unmount: Optional[EventType[[], BASE_STATE]] = None,
**props,
) -> "GhostUpload":
"""Create the component.
Args:
*children: The children of the component.
on_drop: Fired when files are dropped.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
class_name: The class name for the component.
autofocus: Whether the component should take the focus once the page is loaded
custom_attrs: custom attribute
**props: The props of the component.
Returns:
The component.
"""
...
class Upload(MemoizationLeaf):
is_used: ClassVar[bool] = False

View File

@ -112,6 +112,9 @@ class RadixThemesComponent(Component):
library = "@radix-ui/themes@^3.0.0"
# Temporary pin < 3.1.5 until radix-ui/themes#627 is resolved.
library = library + " && <3.1.5"
# "Fake" prop color_scheme is used to avoid shadowing CSS prop "color".
_rename_props: Dict[str, str] = {"colorScheme": "color"}

View File

@ -46,6 +46,7 @@ from reflex import event
from reflex.config import get_config
from reflex.istate.data import RouterData
from reflex.istate.storage import ClientStorageBase
from reflex.model import Model
from reflex.vars.base import (
ComputedVar,
DynamicRouteVar,
@ -1733,15 +1734,20 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
if value is None:
continue
hinted_args = value_inside_optional(hinted_args)
if (
isinstance(value, dict)
and inspect.isclass(hinted_args)
and (
dataclasses.is_dataclass(hinted_args)
or issubclass(hinted_args, Base)
)
):
payload[arg] = hinted_args(**value)
if isinstance(value, dict) and inspect.isclass(hinted_args):
if issubclass(hinted_args, Model):
# Remove non-fields from the payload
payload[arg] = hinted_args(
**{
key: value
for key, value in value.items()
if key in hinted_args.__fields__
}
)
elif dataclasses.is_dataclass(hinted_args) or issubclass(
hinted_args, Base
):
payload[arg] = hinted_args(**value)
if isinstance(value, list) and (hinted_args is set or hinted_args is Set):
payload[arg] = set(value)
if isinstance(value, list) and (

View File

@ -4,6 +4,7 @@ from reflex.components.core.banner import (
ConnectionPulser,
WebsocketTargetURL,
)
from reflex.components.radix.themes.base import RadixThemesComponent
from reflex.components.radix.themes.typography.text import Text
@ -24,7 +25,7 @@ def test_connection_banner():
"react",
"$/utils/context",
"$/utils/state",
"@radix-ui/themes@^3.0.0",
RadixThemesComponent().library or "",
"$/env.json",
)
)
@ -42,7 +43,7 @@ def test_connection_modal():
"react",
"$/utils/context",
"$/utils/state",
"@radix-ui/themes@^3.0.0",
RadixThemesComponent().library or "",
"$/env.json",
)
)