From da9621c23ac9861030227752a16cdb9588ee6c19 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Fri, 25 Aug 2023 09:00:15 -0400 Subject: [PATCH 1/3] use typed-builder 0.15 --- leptos/Cargo.toml | 3 ++- leptos/src/lib.rs | 7 ++++++- leptos_config/Cargo.toml | 2 +- leptos_macro/Cargo.toml | 2 +- leptos_macro/src/component.rs | 11 ++++++++--- leptos_macro/src/slot.rs | 4 ++-- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/leptos/Cargo.toml b/leptos/Cargo.toml index e4ca533f2d..76e925eb30 100644 --- a/leptos/Cargo.toml +++ b/leptos/Cargo.toml @@ -16,7 +16,8 @@ leptos_reactive = { workspace = true } leptos_server = { workspace = true } leptos_config = { workspace = true } tracing = "0.1" -typed-builder = "0.14" +typed-builder = { git = "https://github.com/idanarye/rust-typed-builder", branch = "feature/issue-109-setting-crate_module_path" } +typed-builder-macro = { git = "https://github.com/idanarye/rust-typed-builder", branch = "feature/issue-109-setting-crate_module_path" } server_fn = { workspace = true } web-sys = { version = "0.3.63", optional = true } wasm-bindgen = { version = "0.2", optional = true } diff --git a/leptos/src/lib.rs b/leptos/src/lib.rs index 36a0ea6500..b1d9b85e6c 100644 --- a/leptos/src/lib.rs +++ b/leptos/src/lib.rs @@ -175,7 +175,6 @@ pub use leptos_server::{ ServerFnErrorErr, }; pub use server_fn::{self, ServerFn as _}; -pub use typed_builder; #[cfg(all(target_arch = "wasm32", feature = "template_macro"))] pub use {leptos_macro::template, wasm_bindgen, web_sys}; mod error_boundary; @@ -195,6 +194,12 @@ pub use text_prop::TextProp; #[doc(hidden)] pub use tracing; pub use transition::*; +#[doc(hidden)] +pub use typed_builder; +#[doc(hidden)] +pub use typed_builder::Optional; +#[doc(hidden)] +pub use typed_builder_macro; extern crate self as leptos; /// The most common type for the `children` property on components, diff --git a/leptos_config/Cargo.toml b/leptos_config/Cargo.toml index da29d6f60d..20d8d288d0 100644 --- a/leptos_config/Cargo.toml +++ b/leptos_config/Cargo.toml @@ -13,7 +13,7 @@ config = "0.13.3" regex = "1.7.0" serde = { version = "1.0.151", features = ["derive"] } thiserror = "1.0.38" -typed-builder = "0.14" +typed-builder = { git = "https://github.com/idanarye/rust-typed-builder", branch = "feature/issue-109-setting-crate_module_path" } [dev-dependencies] tokio = { version = "1", features = ["rt", "macros"] } diff --git a/leptos_macro/Cargo.toml b/leptos_macro/Cargo.toml index 9c3a0d19d0..c829cb4b41 100644 --- a/leptos_macro/Cargo.toml +++ b/leptos_macro/Cargo.toml @@ -30,7 +30,7 @@ tracing = "0.1.37" [dev-dependencies] log = "0.4" -typed-builder = "0.14" +typed-builder = { git = "https://github.com/idanarye/rust-typed-builder", branch = "feature/issue-109-setting-crate_module_path" } trybuild = "1" leptos = { path = "../leptos" } insta = "1.29" diff --git a/leptos_macro/src/component.rs b/leptos_macro/src/component.rs index e5f2774813..163ed5d66d 100644 --- a/leptos_macro/src/component.rs +++ b/leptos_macro/src/component.rs @@ -252,8 +252,9 @@ impl ToTokens for Model { #[doc = ""] #docs #component_fn_prop_docs - #[derive(::leptos::typed_builder::TypedBuilder)] - #[builder(doc)] + #[derive(::leptos::typed_builder_macro::TypedBuilder)] + //#[builder(doc)] + #[builder(crate_module_path=::leptos::typed_builder)] #vis struct #props_name #impl_generics #where_clause { #prop_builder_fields } @@ -554,7 +555,11 @@ impl ToTokens for TypedBuilderOpts { quote! {} }; - let output = quote! { #[builder(#default #setter)] }; + let output = if !default.is_empty() || !setter.is_empty() { + quote! { #[builder(#default #setter)] } + } else { + quote! {} + }; tokens.append_all(output); } diff --git a/leptos_macro/src/slot.rs b/leptos_macro/src/slot.rs index d149d99461..033a6f9e0a 100644 --- a/leptos_macro/src/slot.rs +++ b/leptos_macro/src/slot.rs @@ -79,8 +79,8 @@ impl ToTokens for Model { #[doc = ""] #docs #prop_docs - #[derive(::leptos::typed_builder::TypedBuilder)] - #[builder(doc)] + #[derive(::leptos::typed_builder_macro::TypedBuilder)] + #[builder(doc, crate_module_path=::leptos::typed_builder)] #vis struct #name #generics #where_clause { #prop_builder_fields } From b3e573645abc54f80a94b53c5dc932c6bb261637 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Fri, 25 Aug 2023 22:33:37 -0400 Subject: [PATCH 2/3] use 0.16 --- leptos/Cargo.toml | 4 ++-- leptos_config/Cargo.toml | 2 +- leptos_macro/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/leptos/Cargo.toml b/leptos/Cargo.toml index 76e925eb30..eb912796ab 100644 --- a/leptos/Cargo.toml +++ b/leptos/Cargo.toml @@ -16,8 +16,8 @@ leptos_reactive = { workspace = true } leptos_server = { workspace = true } leptos_config = { workspace = true } tracing = "0.1" -typed-builder = { git = "https://github.com/idanarye/rust-typed-builder", branch = "feature/issue-109-setting-crate_module_path" } -typed-builder-macro = { git = "https://github.com/idanarye/rust-typed-builder", branch = "feature/issue-109-setting-crate_module_path" } +typed-builder = "0.16" +typed-builder-macro = "0.16" server_fn = { workspace = true } web-sys = { version = "0.3.63", optional = true } wasm-bindgen = { version = "0.2", optional = true } diff --git a/leptos_config/Cargo.toml b/leptos_config/Cargo.toml index 20d8d288d0..f6aca0f2dc 100644 --- a/leptos_config/Cargo.toml +++ b/leptos_config/Cargo.toml @@ -13,7 +13,7 @@ config = "0.13.3" regex = "1.7.0" serde = { version = "1.0.151", features = ["derive"] } thiserror = "1.0.38" -typed-builder = { git = "https://github.com/idanarye/rust-typed-builder", branch = "feature/issue-109-setting-crate_module_path" } +typed-builder = "0.16" [dev-dependencies] tokio = { version = "1", features = ["rt", "macros"] } diff --git a/leptos_macro/Cargo.toml b/leptos_macro/Cargo.toml index c829cb4b41..6e70db516a 100644 --- a/leptos_macro/Cargo.toml +++ b/leptos_macro/Cargo.toml @@ -30,7 +30,7 @@ tracing = "0.1.37" [dev-dependencies] log = "0.4" -typed-builder = { git = "https://github.com/idanarye/rust-typed-builder", branch = "feature/issue-109-setting-crate_module_path" } +typed-builder = "0.16" trybuild = "1" leptos = { path = "../leptos" } insta = "1.29" From f3865b52ed6be02fb861819f71674d6660f52c10 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sat, 26 Aug 2023 07:25:47 -0400 Subject: [PATCH 3/3] fix empty `#[builder()]` in slots --- leptos_macro/src/slot.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/leptos_macro/src/slot.rs b/leptos_macro/src/slot.rs index 033a6f9e0a..f13487a3a2 100644 --- a/leptos_macro/src/slot.rs +++ b/leptos_macro/src/slot.rs @@ -191,7 +191,11 @@ impl ToTokens for TypedBuilderOpts { quote! {} }; - let output = quote! { #[builder(#default #setter)] }; + let output = if !default.is_empty() || !setter.is_empty() { + quote! { #[builder(#default #setter)] } + } else { + quote! {} + }; tokens.append_all(output); }