@@ -29,6 +30,48 @@ pub fn App() -> impl IntoView {
}
}
+use leptos::*;
+
+#[island]
+pub fn CommonIsland() -> impl IntoView {
+ let val = RwSignal::new(0);
+ view! {
+
+ {move || format!("CommonIsland value is {}", val.get())}
+
+
+
+ }
+}
+
+#[island]
+pub fn OuterWorking(children: Children) -> impl IntoView {
+ let val = RwSignal::new(0);
+ view! {
+ <>
+
+ {move || format!("outer value is {}", val.get())}
+
+
+ {children()}
+ >
+
+ }
+}
+
+#[component]
+pub fn Example() -> impl IntoView {
+ view! {
+
+
+
+
+
+
+
+ }
+}
+
#[cfg(feature = "hydrate")]
#[wasm_bindgen::prelude::wasm_bindgen]
pub fn hydrate() {
diff --git a/leptos/Cargo.toml b/leptos/Cargo.toml
index 514eda8ac..cedb39fe6 100644
--- a/leptos/Cargo.toml
+++ b/leptos/Cargo.toml
@@ -24,10 +24,11 @@ paste = "1"
rand = { version = "0.8", optional = true }
reactive_graph = { workspace = true, features = ["serde"] }
tachys = { workspace = true, features = ["reactive_graph"] }
+thiserror = "1"
tracing = "0.1"
typed-builder = "0.18"
typed-builder-macro = "0.18"
-serde = { version = "1", optional = true }
+serde = "1"
serde_json = { version = "1", optional = true }
server_fn = { workspace = true, features = [
"form-redirects",
@@ -41,6 +42,7 @@ web-sys = { version = "0.3.63", features = [
"ShadowRootMode",
] }
wasm-bindgen = { version = "0.2", optional = true }
+serde_qs = "0.12.0"
[features]
default = ["serde"]
@@ -78,7 +80,6 @@ experimental-islands = [
"leptos_dom/experimental-islands",
"leptos_macro/experimental-islands",
"leptos_reactive/experimental-islands",
- "dep:serde",
"dep:serde_json",
]
trace-component-props = [
diff --git a/leptos/src/action_form.rs b/leptos/src/action_form.rs
new file mode 100644
index 000000000..53f196957
--- /dev/null
+++ b/leptos/src/action_form.rs
@@ -0,0 +1,180 @@
+use crate::{
+ children::Children, component, from_form_data::FromFormData, prelude::*,
+ IntoView,
+};
+use leptos_dom::{events::submit, helpers::window};
+use leptos_server::ServerAction;
+use serde::de::DeserializeOwned;
+use server_fn::{
+ client::Client, codec::PostUrl, request::ClientReq, ServerFn, ServerFnError,
+};
+use tachys::{
+ either::Either,
+ html::{
+ attribute::any_attribute::AnyAttribute,
+ element::{form, Form},
+ },
+ reactive_graph::node_ref::NodeRef,
+ renderer::dom::Dom,
+};
+use web_sys::{FormData, SubmitEvent};
+
+/// Automatically turns a server [Action](leptos_server::Action) into an HTML
+/// [`form`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
+/// progressively enhanced to use client-side routing.
+///
+/// ## Encoding
+/// **Note:** `` only works with server functions that use the
+/// default `Url` encoding. This is to ensure that `` works correctly
+/// both before and after WASM has loaded.
+///
+/// ## Complex Inputs
+/// Server function arguments that are structs with nested serializable fields
+/// should make use of indexing notation of `serde_qs`.
+///
+/// ```rust
+/// # use leptos::*;
+/// # use leptos_router::*;
+///
+/// #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
+/// struct HeftyData {
+/// first_name: String,
+/// last_name: String,
+/// }
+///
+/// #[component]
+/// fn ComplexInput() -> impl IntoView {
+/// let submit = Action::::server();
+///
+/// view! {
+///
+///
+///
+///
+///
+/// }
+/// }
+///
+/// #[server]
+/// async fn very_important_fn(
+/// hefty_arg: HeftyData,
+/// ) -> Result<(), ServerFnError> {
+/// assert_eq!(hefty_arg.first_name.as_str(), "leptos");
+/// assert_eq!(hefty_arg.last_name.as_str(), "closures-everywhere");
+/// Ok(())
+/// }
+/// ```
+#[cfg_attr(
+ any(debug_assertions, feature = "ssr"),
+ tracing::instrument(level = "trace", skip_all,)
+)]
+#[component]
+pub fn ActionForm(
+ /// The action from which to build the form. This should include a URL, which can be generated
+ /// by default using [`create_server_action`](leptos_server::create_server_action) or added
+ /// manually using [`using_server_fn`](leptos_server::Action::using_server_fn).
+ action: ServerAction,
+ /// A [`NodeRef`] in which the `