Skip to content

Commit

Permalink
feat: update to typed-builder 0.16 (closes #1455) (#1590)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj authored Aug 26, 2023
1 parent 08c419e commit 6c3e2fe
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
3 changes: 2 additions & 1 deletion leptos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "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 }
Expand Down
7 changes: 6 additions & 1 deletion leptos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion leptos_config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "0.16"

[dev-dependencies]
tokio = { version = "1", features = ["rt", "macros"] }
Expand Down
2 changes: 1 addition & 1 deletion leptos_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tracing = "0.1.37"

[dev-dependencies]
log = "0.4"
typed-builder = "0.14"
typed-builder = "0.16"
trybuild = "1"
leptos = { path = "../leptos" }
insta = "1.29"
Expand Down
11 changes: 8 additions & 3 deletions leptos_macro/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 7 additions & 3 deletions leptos_macro/src/slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 6c3e2fe

Please sign in to comment.