Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into axum_7
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsantana committed Nov 30, 2023
2 parents 3b841de + 19711e1 commit e6a8500
Show file tree
Hide file tree
Showing 32 changed files with 1,198 additions and 417 deletions.
28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ members = [
exclude = ["benchmarks", "examples"]

[workspace.package]
version = "0.5.3"
version = "0.5.4"

[workspace.dependencies]
leptos = { path = "./leptos", version = "0.5.3" }
leptos_dom = { path = "./leptos_dom", version = "0.5.3" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.5.3" }
leptos_macro = { path = "./leptos_macro", version = "0.5.3" }
leptos_reactive = { path = "./leptos_reactive", version = "0.5.3" }
leptos_server = { path = "./leptos_server", version = "0.5.3" }
server_fn = { path = "./server_fn", version = "0.5.3" }
server_fn_macro = { path = "./server_fn_macro", version = "0.5.3" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.5.3" }
leptos_config = { path = "./leptos_config", version = "0.5.3" }
leptos_router = { path = "./router", version = "0.5.3" }
leptos_meta = { path = "./meta", version = "0.5.3" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.5.3" }
leptos = { path = "./leptos", version = "0.5.4" }
leptos_dom = { path = "./leptos_dom", version = "0.5.4" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.5.4" }
leptos_macro = { path = "./leptos_macro", version = "0.5.4" }
leptos_reactive = { path = "./leptos_reactive", version = "0.5.4" }
leptos_server = { path = "./leptos_server", version = "0.5.4" }
server_fn = { path = "./server_fn", version = "0.5.4" }
server_fn_macro = { path = "./server_fn_macro", version = "0.5.4" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.5.4" }
leptos_config = { path = "./leptos_config", version = "0.5.4" }
leptos_router = { path = "./router", version = "0.5.4" }
leptos_meta = { path = "./meta", version = "0.5.4" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.5.4" }

[profile.release]
codegen-units = 1
Expand Down
6 changes: 3 additions & 3 deletions docs/book/src/interlude_projecting_children.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,17 @@ pub fn App() -> impl IntoView {
}

#[component]
pub fn Outer(ChildrenFn) -> impl IntoView {
pub fn Outer(children: ChildrenFn) -> impl IntoView {
children()
}

#[component]
pub fn Inner(ChildrenFn) -> impl IntoView {
pub fn Inner(children: ChildrenFn) -> impl IntoView {
children()
}

#[component]
pub fn Inmost(ng) -> impl IntoView {
pub fn Inmost(name: String) -> impl IntoView {
view! {
<p>{name}</p>
}
Expand Down
78 changes: 38 additions & 40 deletions docs/book/src/reactivity/14_create_effect.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,20 @@ set_num.set(2); // (nothing happens)
use leptos::html::Input;
use leptos::*;

#[derive(Copy, Clone)]
struct LogContext(RwSignal<Vec<String>>);

#[component]
fn App() -> impl IntoView {
// Just making a visible log here
// You can ignore this...
let log = create_rw_signal::<Vec<String>>(vec![]);
let logged = move || log().join("\n");
provide_context(log);

// the newtype pattern isn't *necessary* here but is a good practice
// it avoids confusion with other possible future `RwSignal<Vec<String>>` contexts
// and makes it easier to refer to it
provide_context(LogContext(log));

view! {
<CreateAnEffect/>
Expand All @@ -169,34 +176,43 @@ fn CreateAnEffect() -> impl IntoView {
// this will add the name to the log
// any time one of the source signals changes
create_effect(move |_| {
log(

if use_last() {
format!("{} {}", first(), last())
} else {
first()
},
)
log(if use_last() {
with!(|first, last| format!("{first} {last}"))
} else {
first()
})
});

view! {
<h1><code>"create_effect"</code> " Version"</h1>
<h1>
<code>"create_effect"</code>
" Version"
</h1>
<form>
<label>
"First Name"
<input type="text" name="first" prop:value=first
<input
type="text"
name="first"
prop:value=first
on:change=move |ev| set_first(event_target_value(&ev))
/>
</label>
<label>
"Last Name"
<input type="text" name="last" prop:value=last
<input
type="text"
name="last"
prop:value=last
on:change=move |ev| set_last(event_target_value(&ev))
/>
</label>
<label>
"Show Last Name"
<input type="checkbox" name="use_last" prop:checked=use_last
<input
type="checkbox"
name="use_last"
prop:checked=use_last
on:change=move |ev| set_use_last(event_target_checked(&ev))
/>
</label>
Expand Down Expand Up @@ -231,24 +247,10 @@ fn ManualVersion() -> impl IntoView {
view! {
<h1>"Manual Version"</h1>
<form on:change=on_change>
<label>"First Name" <input type="text" name="first" node_ref=first/></label>
<label>"Last Name" <input type="text" name="last" node_ref=last/></label>
<label>
"First Name"
<input type="text" name="first"
node_ref=first
/>
</label>
<label>
"Last Name"
<input type="text" name="last"
node_ref=last
/>
</label>
<label>
"Show Last Name"
<input type="checkbox" name="use_last"
checked
node_ref=use_last
/>
"Show Last Name" <input type="checkbox" name="use_last" checked node_ref=use_last/>
</label>
</form>
}
Expand All @@ -273,20 +275,16 @@ fn EffectVsDerivedSignal() -> impl IntoView {
move || (!my_value.with(String::is_empty)).then(|| Some(my_value.get()));

view! {
<input
prop:value=my_value
on:input= move |ev| set_my_value(event_target_value(&ev))
/>
<input prop:value=my_value on:input=move |ev| set_my_value(event_target_value(&ev))/>

<p>
<code>"my_optional_value"</code>
" is "
<code>
<Show
when=move || my_optional_value().is_some()
fallback=|| view! { "None" }
>
"Some(\"" {my_optional_value().unwrap()} "\")"
<Show when=move || my_optional_value().is_some() fallback=|| view! { "None" }>
"Some(\""
{my_optional_value().unwrap()}
"\")"
</Show>
</code>
</p>
Expand Down Expand Up @@ -316,7 +314,7 @@ where
}

fn log(msg: impl std::fmt::Display) {
let log = use_context::<RwSignal<Vec<String>>>().unwrap();
let log = use_context::<LogContext>().unwrap().0;
log.update(|log| log.push(msg.to_string()));
}

Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/reactivity/working_with_signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ let memoized_double_count = create_memo(move |_| count() * 2);
```rust
let (first_name, set_first_name) = create_signal("Bridget".to_string());
let (last_name, set_last_name) = create_signal("Jones".to_string());
let full_name = move || format!("{} {}", first_name(), last_name());
let full_name = move || with!(|first_name, last_name| format!("{first_name} {last_name}"));
```

**3) A and B are independent signals, but sometimes updated at the same time.** When you make the call to update A, make a separate call to update B.
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct Todos(Vec<Todo>);

impl Todos {
pub fn num_remaining(&self) -> usize {
todos.iter().filter(|todo| !todo.completed).sum()
self.0.iter().filter(|todo| !todo.completed).sum()
}
}

Expand Down
4 changes: 2 additions & 2 deletions docs/book/src/view/04b_iteration.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ You’ll notice a few differences here:
Every time `data` changes, now, each memo will be recalculated. If its value has changed,
it will update its text node, without rerendering the whole row.

## Pros
### Pros

We get the same fine-grained reactivity of the signal-wrapped version, without needing to
wrap the data in signals.

## Cons
### Cons

It’s a bit more complex to set up this memo-per-row inside the `<For/>` loop rather than
using nested signals. For example, you’ll notice that we have to guard against the possibility
Expand Down
5 changes: 3 additions & 2 deletions docs/book/src/view/08_parent_child.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub fn App() -> impl IntoView {


#[component]
pub fn ButtonC<F>() -> impl IntoView {
pub fn ButtonC() -> impl IntoView {
view! {
<button>"Toggle"</button>
}
Expand Down Expand Up @@ -261,7 +261,7 @@ Isn’t there some way to skip levels?

There is!

### The Context API
### 4.1 The Context API

You can provide data that skips levels by using [`provide_context`](https://docs.rs/leptos/latest/leptos/fn.provide_context.html)
and [`use_context`](https://docs.rs/leptos/latest/leptos/fn.use_context.html). Contexts are identified
Expand All @@ -284,6 +284,7 @@ pub fn App() -> impl IntoView {
}

// <Layout/> and <Content/> omitted
// To work in this version, drop their references to set_toggled

#[component]
pub fn ButtonD() -> impl IntoView {
Expand Down
4 changes: 2 additions & 2 deletions examples/tailwind_axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ denylist = ["axum", "tokio", "tower", "tower-http", "leptos_axum"]
skip_feature_sets = [["ssr", "hydrate"]]

[package.metadata.leptos]
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
output-name = "tailwind"
# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
site-root = "target/site"
# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
# Defaults to pkg
# Defaults to pkg
site-pkg-dir = "pkg"
# The tailwind input file.
#
Expand Down
2 changes: 1 addition & 1 deletion examples/todo_app_sqlite_viz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ simple_logger = "4.0.0"
serde = { version = "1", features = ["derive"] }
viz = { version = "0.4.8", features = ["serve"], optional = true }
tokio = { version = "1.25.0", features = ["full"], optional = true }
http = { version = "0.2.8" }
http = { version = "0.2.11" }
sqlx = { version = "0.6.2", features = [
"runtime-tokio-rustls",
"sqlite",
Expand Down
2 changes: 1 addition & 1 deletion integrations/axum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! To run in this environment, you need to disable the default feature set and enable
//! the `wasm` feature on `leptos_axum` in your `Cargo.toml`.
//! ```toml
//! leptos_axum = { version = "0.5.3", default-features = false, features = ["wasm"] }
//! leptos_axum = { version = "0.5.4", default-features = false, features = ["wasm"] }
//! ```
//!
//! ## Features
Expand Down
2 changes: 1 addition & 1 deletion integrations/viz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "Viz integrations for the Leptos web framework."
[dependencies]
viz = { version = "0.4.8" }
futures = "0.3"
http = "0.2.8"
http = "0.2.11"
hyper = "0.14.23"
leptos = { workspace = true, features = ["ssr"] }
leptos_meta = { workspace = true, features = ["ssr"] }
Expand Down
24 changes: 13 additions & 11 deletions leptos_macro/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl ToTokens for Model {
} else {
quote! {
::leptos::leptos_dom::Component::new(
stringify!(#name),
::std::stringify!(#name),
move || {
#tracing_guard_expr
#tracing_props_expr
Expand Down Expand Up @@ -291,13 +291,14 @@ impl ToTokens for Model {
&& cfg!(feature = "ssr")
{
quote! {
let children = Box::new(|| ::leptos::Fragment::lazy(|| vec![
let children = ::std::boxed::Box::new(|| ::leptos::Fragment::lazy(|| ::std::vec![
::leptos::SharedContext::with_hydration(move || {
::leptos::leptos_dom::html::custom(
::leptos::leptos_dom::html::Custom::new("leptos-children"),
::leptos::IntoView::into_view(
::leptos::leptos_dom::html::custom(
::leptos::leptos_dom::html::Custom::new("leptos-children"),
)
.child(::leptos::SharedContext::no_hydration(children))
)
.child(::leptos::SharedContext::no_hydration(children))
.into_view()
})
]));
}
Expand Down Expand Up @@ -411,13 +412,14 @@ impl ToTokens for Model {
};
let children = if is_island_with_children {
quote! {
.children(Box::new(move || ::leptos::Fragment::lazy(|| vec![
.children(::std::boxed::Box::new(move || ::leptos::Fragment::lazy(|| ::std::vec![
::leptos::SharedContext::with_hydration(move || {
::leptos::leptos_dom::html::custom(
::leptos::leptos_dom::html::Custom::new("leptos-children"),
::leptos::IntoView::into_view(
::leptos::leptos_dom::html::custom(
::leptos::leptos_dom::html::Custom::new("leptos-children"),
)
.prop("$$owner", ::leptos::Owner::current().map(|n| n.as_ffi()))
)
.prop("$$owner", ::leptos::Owner::current().map(|n| n.as_ffi()))
.into_view()
})])))
}
} else {
Expand Down
5 changes: 4 additions & 1 deletion leptos_macro/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ pub fn params_impl(ast: &syn::DeriveInput) -> proc_macro::TokenStream {
let span = field.span();

quote_spanned! {
span => #ident: <#ty>::into_param(map.get(#field_name_string).map(::std::string::String::as_str), #field_name_string)?
span=> #ident: <#ty as ::leptos_router::IntoParam>::into_param(
map.get(#field_name_string).map(::std::string::String::as_str),
#field_name_string
)?
}
})
.collect()
Expand Down
Loading

0 comments on commit e6a8500

Please sign in to comment.