diff --git a/packages/html/Cargo.toml b/packages/html/Cargo.toml
index 1c5561cc7..d3efc839b 100644
--- a/packages/html/Cargo.toml
+++ b/packages/html/Cargo.toml
@@ -24,7 +24,7 @@ serde-value = "0.7.0"
tokio = { workspace = true, features = ["fs", "io-util"], optional = true }
rfd = { version = "0.12", optional = true }
async-channel = "1.8.0"
-serde_json = { version = "1" }
+serde_json = { version = "1", optional = true }
[dependencies.web-sys]
optional = true
diff --git a/packages/html/src/events/form.rs b/packages/html/src/events/form.rs
index bc052bbe2..ee69104b9 100644
--- a/packages/html/src/events/form.rs
+++ b/packages/html/src/events/form.rs
@@ -1,4 +1,4 @@
-use std::{any::Any, collections::HashMap, fmt::Debug};
+use std::{any::Any, collections::HashMap, fmt::Debug, sync::Arc};
use dioxus_core::Event;
use serde::{Deserialize, Serialize};
@@ -14,20 +14,13 @@ pub enum FormValue {
}
/* DOMEvent: Send + SyncTarget relatedTarget */
-#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
-#[derive(Clone)]
pub struct FormData {
inner: Box,
- pub values: HashMap,
}
impl From for FormData {
fn from(e: E) -> Self {
- // todo: fix this?
- Self {
- inner: Box::new(e),
- values: Default::default(),
- }
+ Self { inner: Box::new(e) }
}
}
@@ -51,7 +44,6 @@ impl FormData {
pub fn new(event: impl HasFormData + 'static) -> Self {
Self {
inner: Box::new(event),
- values: Default::default(),
}
}
@@ -61,7 +53,7 @@ impl FormData {
}
/// Get the values of the form event
- pub fn values(&self) -> HashMap> {
+ pub fn values(&self) -> HashMap {
self.inner.values()
}
@@ -82,7 +74,7 @@ pub trait HasFormData: std::any::Any {
Default::default()
}
- fn values(&self) -> HashMap> {
+ fn values(&self) -> HashMap {
Default::default()
}
@@ -109,7 +101,7 @@ impl FormData {
T: serde::de::DeserializeOwned,
{
let parsed_json =
- convert_hashmap_to_json(&self.values).expect("Failed to parse values to JSON");
+ convert_hashmap_to_json(&self.values()).expect("Failed to parse values to JSON");
serde_json::from_str(&parsed_json)
}
@@ -120,8 +112,8 @@ impl FormData {
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Clone)]
pub struct SerializedFormData {
value: String,
- values: HashMap>,
- files: Option>,
+ values: HashMap,
+ files: Option,
}
#[cfg(feature = "serialize")]
@@ -129,8 +121,8 @@ impl SerializedFormData {
/// Create a new serialized form data object
pub fn new(
value: String,
- values: HashMap>,
- files: Option>,
+ values: HashMap,
+ files: Option,
) -> Self {
Self {
value,
@@ -153,9 +145,9 @@ impl SerializedFormData {
resolved_files.insert(file, bytes.unwrap_or_default());
}
- Some(std::sync::Arc::new(SerializedFileEngine {
+ Some(SerializedFileEngine {
files: resolved_files,
- }))
+ })
}
None => None,
},
@@ -177,14 +169,14 @@ impl HasFormData for SerializedFormData {
self.value.clone()
}
- fn values(&self) -> HashMap> {
+ fn values(&self) -> HashMap {
self.values.clone()
}
fn files(&self) -> Option> {
self.files
.as_ref()
- .map(|files| std::sync::Arc::clone(files) as std::sync::Arc)
+ .map(|files| Arc::new(files.clone()) as _)
}
fn as_any(&self) -> &dyn std::any::Any {
@@ -240,36 +232,6 @@ impl FileEngine for SerializedFileEngine {
}
}
-#[cfg(feature = "serialize")]
-fn deserialize_file_engine<'de, D>(
- deserializer: D,
-) -> Result