rx.upload must include _var_data from props
str-casting the dropzone arguments removed any VarData they depended on, like the state context. update test_upload to include passing a prop from a state var
This commit is contained in:
parent
a320d062fb
commit
3cf32817f5
@ -293,13 +293,15 @@ class Upload(MemoizationLeaf):
|
|||||||
format.to_camel_case(key): value for key, value in upload_props.items()
|
format.to_camel_case(key): value for key, value in upload_props.items()
|
||||||
}
|
}
|
||||||
|
|
||||||
use_dropzone_arguments = {
|
use_dropzone_arguments = Var.create(
|
||||||
|
{
|
||||||
"onDrop": event_var,
|
"onDrop": event_var,
|
||||||
**upload_props,
|
**upload_props,
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
left_side = f"const {{getRootProps: {root_props_unique_name}, getInputProps: {input_props_unique_name}}} "
|
left_side = f"const {{getRootProps: {root_props_unique_name}, getInputProps: {input_props_unique_name}}} "
|
||||||
right_side = f"useDropzone({str(Var.create(use_dropzone_arguments))})"
|
right_side = f"useDropzone({str(use_dropzone_arguments)})"
|
||||||
|
|
||||||
var_data = VarData.merge(
|
var_data = VarData.merge(
|
||||||
VarData(
|
VarData(
|
||||||
@ -307,6 +309,7 @@ class Upload(MemoizationLeaf):
|
|||||||
hooks={Hooks.EVENTS: None},
|
hooks={Hooks.EVENTS: None},
|
||||||
),
|
),
|
||||||
event_var._get_all_var_data(),
|
event_var._get_all_var_data(),
|
||||||
|
use_dropzone_arguments._get_all_var_data(),
|
||||||
VarData(
|
VarData(
|
||||||
hooks={
|
hooks={
|
||||||
callback_str: None,
|
callback_str: None,
|
||||||
|
@ -23,6 +23,7 @@ def UploadFile():
|
|||||||
_file_data: Dict[str, str] = {}
|
_file_data: Dict[str, str] = {}
|
||||||
event_order: List[str] = []
|
event_order: List[str] = []
|
||||||
progress_dicts: List[dict] = []
|
progress_dicts: List[dict] = []
|
||||||
|
disabled: bool = False
|
||||||
|
|
||||||
async def handle_upload(self, files: List[rx.UploadFile]):
|
async def handle_upload(self, files: List[rx.UploadFile]):
|
||||||
for file in files:
|
for file in files:
|
||||||
@ -56,6 +57,7 @@ def UploadFile():
|
|||||||
rx.button("Select File"),
|
rx.button("Select File"),
|
||||||
rx.text("Drag and drop files here or click to select files"),
|
rx.text("Drag and drop files here or click to select files"),
|
||||||
),
|
),
|
||||||
|
disabled=UploadState.disabled,
|
||||||
),
|
),
|
||||||
rx.button(
|
rx.button(
|
||||||
"Upload",
|
"Upload",
|
||||||
|
Loading…
Reference in New Issue
Block a user