Skip to content

Commit 4afea2d

Browse files
adhami3310masenf
authored andcommitted
fix upload argspec being missing (#4335)
1 parent 103069a commit 4afea2d

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

reflex/components/core/upload.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pathlib import Path
66
from typing import Any, Callable, ClassVar, Dict, List, Optional, Tuple
77

8+
from reflex.components.base.fragment import Fragment
89
from reflex.components.component import (
910
Component,
1011
ComponentNamespace,
@@ -181,6 +182,13 @@ class UploadFilesProvider(Component):
181182
tag = "UploadFilesProvider"
182183

183184

185+
class GhostUpload(Fragment):
186+
"""A ghost upload component."""
187+
188+
# Fired when files are dropped.
189+
on_drop: EventHandler[_on_drop_spec]
190+
191+
184192
class Upload(MemoizationLeaf):
185193
"""A file upload component."""
186194

@@ -276,8 +284,8 @@ def create(cls, *children, **props) -> Component:
276284
root_props_unique_name = get_unique_variable_name()
277285

278286
event_var, callback_str = StatefulComponent._get_memoized_event_triggers(
279-
Box.create(on_click=upload_props["on_drop"]) # type: ignore
280-
)["on_click"]
287+
GhostUpload.create(on_drop=upload_props["on_drop"])
288+
)["on_drop"]
281289

282290
upload_props["on_drop"] = event_var
283291

reflex/components/core/upload.pyi

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from pathlib import Path
77
from typing import Any, ClassVar, Dict, List, Optional, Union, overload
88

9+
from reflex.components.base.fragment import Fragment
910
from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
1011
from reflex.constants import Dirs
1112
from reflex.event import BASE_STATE, CallableEventSpec, EventSpec, EventType
@@ -84,6 +85,56 @@ class UploadFilesProvider(Component):
8485
"""
8586
...
8687

88+
class GhostUpload(Fragment):
89+
@overload
90+
@classmethod
91+
def create( # type: ignore
92+
cls,
93+
*children,
94+
style: Optional[Style] = None,
95+
key: Optional[Any] = None,
96+
id: Optional[Any] = None,
97+
class_name: Optional[Any] = None,
98+
autofocus: Optional[bool] = None,
99+
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
100+
on_blur: Optional[EventType[[], BASE_STATE]] = None,
101+
on_click: Optional[EventType[[], BASE_STATE]] = None,
102+
on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
103+
on_double_click: Optional[EventType[[], BASE_STATE]] = None,
104+
on_drop: Optional[
105+
Union[EventType[[], BASE_STATE], EventType[[Any], BASE_STATE]]
106+
] = None,
107+
on_focus: Optional[EventType[[], BASE_STATE]] = None,
108+
on_mount: Optional[EventType[[], BASE_STATE]] = None,
109+
on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
110+
on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
111+
on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
112+
on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
113+
on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
114+
on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
115+
on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
116+
on_scroll: Optional[EventType[[], BASE_STATE]] = None,
117+
on_unmount: Optional[EventType[[], BASE_STATE]] = None,
118+
**props,
119+
) -> "GhostUpload":
120+
"""Create the component.
121+
122+
Args:
123+
*children: The children of the component.
124+
on_drop: Fired when files are dropped.
125+
style: The style of the component.
126+
key: A unique key for the component.
127+
id: The id for the component.
128+
class_name: The class name for the component.
129+
autofocus: Whether the component should take the focus once the page is loaded
130+
custom_attrs: custom attribute
131+
**props: The props of the component.
132+
133+
Returns:
134+
The component.
135+
"""
136+
...
137+
87138
class Upload(MemoizationLeaf):
88139
is_used: ClassVar[bool] = False
89140

0 commit comments

Comments
 (0)