From eb73bff3cd60f28f0aaa99fee4e2d55f53a2c373 Mon Sep 17 00:00:00 2001 From: Maccesch Date: Thu, 22 Aug 2024 17:47:06 +0100 Subject: [PATCH] merged changes from Baptiste Closes #156 --- Cargo.toml | 7 ++++- examples/Cargo.toml | 23 +++++++++------ examples/on_click_outside/Cargo.toml | 16 +++++------ examples/on_click_outside/src/main.rs | 8 ++++-- examples/signal_debounced/Cargo.toml | 16 +++++------ examples/signal_debounced/src/main.rs | 6 ++-- examples/signal_throttled/Cargo.toml | 16 +++++------ examples/signal_throttled/src/main.rs | 6 ++-- examples/ssr/Cargo.toml | 12 +++++--- examples/sync_signal/Cargo.toml | 16 +++++------ examples/sync_signal/src/main.rs | 6 ++-- examples/use_abs/Cargo.toml | 9 ++++-- examples/use_abs/src/main.rs | 6 ++-- examples/use_active_element/Cargo.toml | 9 ++++-- examples/use_active_element/src/main.rs | 6 ++-- examples/use_and/Cargo.toml | 9 ++++-- examples/use_and/src/main.rs | 10 ++++--- examples/use_breakpoints/Cargo.toml | 16 +++++------ examples/use_breakpoints/src/main.rs | 6 ++-- examples/use_broadcast_channel/Cargo.toml | 9 ++++-- examples/use_broadcast_channel/src/main.rs | 6 ++-- examples/use_ceil/Cargo.toml | 9 ++++-- examples/use_ceil/src/main.rs | 6 ++-- examples/use_clipboard/Cargo.toml | 16 +++++------ examples/use_clipboard/src/main.rs | 6 ++-- examples/use_color_mode/Cargo.toml | 16 +++++------ examples/use_color_mode/src/main.rs | 6 ++-- examples/use_cookie/Cargo.toml | 9 ++++-- examples/use_cookie/src/main.rs | 8 ++++-- examples/use_css_var/Cargo.toml | 16 +++++------ examples/use_css_var/src/main.rs | 10 ++++--- examples/use_cycle_list/Cargo.toml | 16 +++++------ examples/use_cycle_list/src/main.rs | 6 ++-- examples/use_debounce_fn/Cargo.toml | 16 +++++------ examples/use_debounce_fn/src/main.rs | 6 ++-- examples/use_device_orientation/Cargo.toml | 16 +++++------ examples/use_device_orientation/src/main.rs | 6 ++-- examples/use_device_pixel_ratio/Cargo.toml | 16 +++++------ examples/use_device_pixel_ratio/src/main.rs | 6 ++-- examples/use_display_media/Cargo.toml | 16 +++++------ examples/use_display_media/src/main.rs | 26 +++++++++++------ examples/use_document_visibility/Cargo.toml | 16 +++++------ examples/use_document_visibility/src/main.rs | 8 ++++-- examples/use_draggable/Cargo.toml | 16 +++++------ examples/use_draggable/src/main.rs | 8 ++++-- examples/use_drop_zone/Cargo.toml | 16 +++++------ examples/use_drop_zone/src/main.rs | 8 ++++-- examples/use_element_bounding/Cargo.toml | 16 +++++------ examples/use_element_bounding/src/main.rs | 8 ++++-- examples/use_element_hover/Cargo.toml | 16 +++++------ examples/use_element_hover/src/main.rs | 8 ++++-- examples/use_element_size/Cargo.toml | 16 +++++------ examples/use_element_size/src/main.rs | 8 ++++-- examples/use_element_visibility/Cargo.toml | 16 +++++------ examples/use_element_visibility/src/main.rs | 8 ++++-- examples/use_event_listener/Cargo.toml | 9 ++++-- examples/use_event_listener/src/main.rs | 4 +-- examples/use_favicon/Cargo.toml | 16 +++++------ examples/use_favicon/src/main.rs | 6 ++-- examples/use_floor/Cargo.toml | 9 ++++-- examples/use_floor/src/main.rs | 6 ++-- examples/use_geolocation/Cargo.toml | 16 +++++------ examples/use_geolocation/src/main.rs | 6 ++-- examples/use_idle/Cargo.toml | 16 +++++------ examples/use_idle/src/main.rs | 6 ++-- examples/use_infinite_scroll/Cargo.toml | 16 +++++------ examples/use_infinite_scroll/src/main.rs | 8 ++++-- examples/use_intersection_observer/Cargo.toml | 16 +++++------ .../use_intersection_observer/src/main.rs | 10 ++++--- examples/use_interval/Cargo.toml | 16 +++++------ examples/use_interval/src/main.rs | 6 ++-- examples/use_interval_fn/Cargo.toml | 9 ++++-- examples/use_interval_fn/src/main.rs | 6 ++-- examples/use_intl_number_format/Cargo.toml | 16 +++++------ examples/use_intl_number_format/src/main.rs | 6 ++-- examples/use_locale/Cargo.toml | 9 ++++-- examples/use_locale/src/main.rs | 8 ++++-- examples/use_locales/Cargo.toml | 16 +++++------ examples/use_locales/src/main.rs | 8 ++++-- examples/use_media_query/Cargo.toml | 16 +++++------ examples/use_media_query/src/main.rs | 6 ++-- examples/use_mouse/Cargo.toml | 16 +++++------ examples/use_mouse/src/main.rs | 8 ++++-- examples/use_mouse_in_element/Cargo.toml | 16 +++++------ examples/use_mouse_in_element/src/main.rs | 8 ++++-- examples/use_mutation_observer/Cargo.toml | 16 +++++------ examples/use_mutation_observer/src/main.rs | 8 ++++-- examples/use_not/Cargo.toml | 9 ++++-- examples/use_not/src/main.rs | 8 ++++-- examples/use_or/Cargo.toml | 9 ++++-- examples/use_or/src/main.rs | 10 ++++--- examples/use_permission/Cargo.toml | 16 +++++------ examples/use_permission/src/main.rs | 9 ++++-- .../use_prefers_reduced_motion/Cargo.toml | 16 +++++------ .../use_prefers_reduced_motion/src/main.rs | 8 ++++-- examples/use_raf_fn/Cargo.toml | 16 +++++------ examples/use_raf_fn/src/main.rs | 6 ++-- examples/use_resize_observer/Cargo.toml | 16 +++++------ examples/use_resize_observer/src/main.rs | 8 ++++-- examples/use_round/Cargo.toml | 9 ++++-- examples/use_round/src/main.rs | 6 ++-- examples/use_scroll/Cargo.toml | 16 +++++------ examples/use_scroll/src/main.rs | 14 ++++++---- examples/use_service_worker/Cargo.toml | 16 +++++------ examples/use_service_worker/src/main.rs | 6 ++-- examples/use_sorted/Cargo.toml | 16 +++++------ examples/use_sorted/src/main.rs | 10 ++++--- examples/use_storage/Cargo.toml | 9 ++++-- examples/use_storage/src/main.rs | 11 +++++--- examples/use_throttle_fn/Cargo.toml | 16 +++++------ examples/use_throttle_fn/src/main.rs | 6 ++-- examples/use_timeout_fn/Cargo.toml | 16 +++++------ examples/use_timeout_fn/src/main.rs | 6 ++-- examples/use_timestamp/Cargo.toml | 16 +++++------ examples/use_timestamp/src/main.rs | 6 ++-- examples/use_user_media/Cargo.toml | 16 +++++------ examples/use_user_media/src/main.rs | 28 +++++++++++++------ examples/use_web_notification/Cargo.toml | 16 +++++------ examples/use_web_notification/src/main.rs | 6 ++-- examples/use_websocket/Cargo.toml | 9 ++++-- examples/use_websocket/src/main.rs | 22 ++++++++------- examples/use_webtransport/Cargo.toml | 16 +++++------ examples/use_webtransport/src/main.rs | 10 ++++--- examples/use_webtransport/src/stream_bidir.rs | 2 +- .../client/Cargo.toml | 5 +++- .../client/src/main.rs | 6 ++-- examples/use_window_focus/Cargo.toml | 16 +++++------ examples/use_window_focus/src/main.rs | 8 ++++-- examples/use_window_scroll/Cargo.toml | 16 +++++------ examples/use_window_scroll/src/main.rs | 6 ++-- examples/watch_debounced/Cargo.toml | 16 +++++------ examples/watch_debounced/src/main.rs | 6 ++-- examples/watch_pausable/Cargo.toml | 16 +++++------ examples/watch_pausable/src/main.rs | 8 ++++-- examples/watch_throttled/Cargo.toml | 16 +++++------ examples/watch_throttled/src/main.rs | 6 ++-- src/core/elements_maybe_signal.rs | 4 +-- src/on_click_outside.rs | 2 +- src/storage/use_storage.rs | 2 +- src/use_css_var.rs | 2 +- src/use_device_orientation.rs | 3 ++ src/use_draggable.rs | 7 ++--- src/use_element_bounding.rs | 2 +- src/use_event_listener.rs | 1 + src/use_event_source.rs | 3 +- src/use_favicon.rs | 2 +- src/use_infinite_scroll.rs | 3 +- src/use_interval_fn.rs | 18 ++++++------ src/use_locales.rs | 15 +++++----- src/use_media_query.rs | 1 + src/use_mouse_in_element.rs | 4 ++- src/use_mutation_observer.rs | 7 +++-- src/use_raf_fn.rs | 5 ++-- src/use_resize_observer.rs | 7 +++-- src/use_service_worker.rs | 5 ++-- src/use_timestamp.rs | 3 +- src/use_web_notification.rs | 15 ++++++---- src/utils/filters/debounce.rs | 3 +- src/utils/filters/throttle.rs | 3 +- src/utils/header.rs | 2 +- src/watch_with_options.rs | 4 +-- .../{{ function_name }}/Cargo.ffizer.hbs.toml | 16 +++++------ 162 files changed, 941 insertions(+), 714 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d89be1a..5f6006f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,12 @@ wasm-bindgen-futures = "0.4" web-sys = { version = "=0.3.70", optional = true } [dev-dependencies] -codee = { version = "0.1", features = ["json_serde", "msgpack_serde", "base64", "prost"] } +codee = { version = "0.1", features = [ + "json_serde", + "msgpack_serde", + "base64", + "prost", +] } getrandom = { version = "0.2", features = ["js"] } leptos_meta = { git = "https://github.com/leptos-rs/leptos" } rand = "0.8" diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 187bcf3..b3893d5 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -7,13 +7,11 @@ members = [ "signal_throttled", "sync_signal", "use_abs", - "use_active_element", "use_and", "use_breakpoints", "use_broadcast_channel", "use_ceil", "use_clipboard", - "use_color_mode", "use_cookie", "use_css_var", "use_cycle_list", @@ -23,7 +21,6 @@ members = [ "use_display_media", "use_document_visibility", "use_draggable", - "use_drop_zone", "use_element_bounding", "use_element_hover", "use_element_size", @@ -61,18 +58,28 @@ members = [ "use_user_media", "use_web_notification", "use_websocket", - "use_webtransport", "use_window_focus", "use_window_scroll", "watch_debounced", "watch_pausable", "watch_throttled", + # "use_active_element", + # "use_color_mode", + # "use_drop_zone", + # "use_webtransport", ] -exclude = [ - "ssr", - "use_webtransport_with_server", -] +exclude = ["ssr", "use_webtransport_with_server"] + +[workspace.dependencies] +leptos = { git = "https://github.com/leptos-rs/leptos" } +console_error_panic_hook = "0.1" +console_log = "1" +log = "0.4" +leptos-use = { path = "..", features = ["docs"] } +web-sys = "0.3" +wasm-bindgen = "0.2" +wasm-bindgen-test = "0.3.0" [package] name = "leptos-use-examples" diff --git a/examples/on_click_outside/Cargo.toml b/examples/on_click_outside/Cargo.toml index c6d6279..2f6ea60 100644 --- a/examples/on_click_outside/Cargo.toml +++ b/examples/on_click_outside/Cargo.toml @@ -4,13 +4,13 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.6", features = ["nightly", "csr"] } -console_error_panic_hook = "0.1" -console_log = "1" -log = "0.4" -leptos-use = { path = "../..", features = ["on_click_outside", "docs"] } -web-sys = "0.3" +leptos = { workspace = true, features = ["nightly", "csr"] } +console_error_panic_hook = { workspace = true } +console_log = { workspace = true } +log = { workspace = true } +leptos-use = { workspace = true, features = ["on_click_outside", "docs"] } +web-sys = { workspace = true } [dev-dependencies] -wasm-bindgen = "0.2" -wasm-bindgen-test = "0.3.0" +wasm-bindgen = { workspace = true } +wasm-bindgen-test = { workspace = true } diff --git a/examples/on_click_outside/src/main.rs b/examples/on_click_outside/src/main.rs index 5588c3f..ec77723 100644 --- a/examples/on_click_outside/src/main.rs +++ b/examples/on_click_outside/src/main.rs @@ -6,7 +6,7 @@ use leptos_use::on_click_outside; #[component] fn Demo() -> impl IntoView { let (show_modal, set_show_modal) = signal(false); - let modal_ref = create_node_ref::
(); + let modal_ref = NodeRef::
::new(); let _ = on_click_outside(modal_ref, move |_| set_show_modal.set(false)); @@ -78,7 +78,9 @@ fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); - mount_to(demo_or_body(), || { + let unmount_handle = leptos::mount::mount_to(demo_or_body(), || { view! { } - }) + }); + + unmount_handle.forget(); } diff --git a/examples/signal_debounced/Cargo.toml b/examples/signal_debounced/Cargo.toml index 9411da3..1e818e3 100644 --- a/examples/signal_debounced/Cargo.toml +++ b/examples/signal_debounced/Cargo.toml @@ -4,13 +4,13 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.6", features = ["nightly", "csr"] } -console_error_panic_hook = "0.1" -console_log = "1" -log = "0.4" -leptos-use = { path = "../..", features = ["signal_debounced", "docs"] } -web-sys = "0.3" +leptos = { workspace = true, features = ["nightly", "csr"] } +console_error_panic_hook = { workspace = true } +console_log = { workspace = true } +log = { workspace = true } +leptos-use = { workspace = true, features = ["signal_debounced", "docs"] } +web-sys = { workspace = true } [dev-dependencies] -wasm-bindgen = "0.2" -wasm-bindgen-test = "0.3.0" +wasm-bindgen = { workspace = true } +wasm-bindgen-test = { workspace = true } diff --git a/examples/signal_debounced/src/main.rs b/examples/signal_debounced/src/main.rs index 07f4c26..a79ece0 100644 --- a/examples/signal_debounced/src/main.rs +++ b/examples/signal_debounced/src/main.rs @@ -26,7 +26,9 @@ fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); - mount_to(demo_or_body(), || { + let unmount_handle = leptos::mount::mount_to(demo_or_body(), || { view! { } - }) + }); + + unmount_handle.forget(); } diff --git a/examples/signal_throttled/Cargo.toml b/examples/signal_throttled/Cargo.toml index 2a14d8a..380cb43 100644 --- a/examples/signal_throttled/Cargo.toml +++ b/examples/signal_throttled/Cargo.toml @@ -4,13 +4,13 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.6", features = ["nightly", "csr"] } -console_error_panic_hook = "0.1" -console_log = "1" -log = "0.4" -leptos-use = { path = "../..", features = ["signal_throttled", "docs"] } -web-sys = "0.3" +leptos = { workspace = true, features = ["nightly", "csr"] } +console_error_panic_hook = { workspace = true } +console_log = { workspace = true } +log = { workspace = true } +leptos-use = { workspace = true, features = ["signal_throttled", "docs"] } +web-sys = { workspace = true } [dev-dependencies] -wasm-bindgen = "0.2" -wasm-bindgen-test = "0.3.0" +wasm-bindgen = { workspace = true } +wasm-bindgen-test = { workspace = true } diff --git a/examples/signal_throttled/src/main.rs b/examples/signal_throttled/src/main.rs index 7468ade..1789b57 100644 --- a/examples/signal_throttled/src/main.rs +++ b/examples/signal_throttled/src/main.rs @@ -26,7 +26,9 @@ fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); - mount_to(demo_or_body(), || { + let unmount_handle = leptos::mount::mount_to(demo_or_body(), || { view! { } - }) + }); + + unmount_handle.forget(); } diff --git a/examples/ssr/Cargo.toml b/examples/ssr/Cargo.toml index 33e9575..59a77b3 100644 --- a/examples/ssr/Cargo.toml +++ b/examples/ssr/Cargo.toml @@ -12,10 +12,14 @@ codee = "0.1" console_error_panic_hook = "0.1" console_log = "1" cfg-if = "1" -leptos = { version = "0.6", features = ["nightly"] } -leptos_axum = { version = "0.6", optional = true } -leptos_meta = { version = "0.6", features = ["nightly"] } -leptos_router = { version = "0.6", features = ["nightly"] } +leptos = { git = "https://github.com/leptos-rs/leptos", features = ["nightly"] } +leptos_axum = { git = "https://github.com/leptos-rs/leptos", optional = true } +leptos_meta = { git = "https://github.com/leptos-rs/leptos", features = [ + "nightly", +] } +leptos_router = { git = "https://github.com/leptos-rs/leptos", features = [ + "nightly", +] } log = "0.4" simple_logger = "4" tokio = { version = "1", features = ["full"], optional = true } diff --git a/examples/sync_signal/Cargo.toml b/examples/sync_signal/Cargo.toml index c072a2b..9f70069 100644 --- a/examples/sync_signal/Cargo.toml +++ b/examples/sync_signal/Cargo.toml @@ -4,13 +4,13 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.6", features = ["nightly", "csr"] } -console_error_panic_hook = "0.1" -console_log = "1" -log = "0.4" -leptos-use = { path = "../..", features = ["sync_signal", "docs"] } -web-sys = "0.3" +leptos = { workspace = true, features = ["nightly", "csr"] } +console_error_panic_hook = { workspace = true } +console_log = { workspace = true } +log = { workspace = true } +leptos-use = { workspace = true, features = ["sync_signal", "docs"] } +web-sys = { workspace = true } [dev-dependencies] -wasm-bindgen = "0.2" -wasm-bindgen-test = "0.3.0" +wasm-bindgen = { workspace = true } +wasm-bindgen-test = { workspace = true } diff --git a/examples/sync_signal/src/main.rs b/examples/sync_signal/src/main.rs index 10ec8da..782c9ef 100644 --- a/examples/sync_signal/src/main.rs +++ b/examples/sync_signal/src/main.rs @@ -19,7 +19,9 @@ fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); - mount_to(demo_or_body(), || { + let unmount_handle = leptos::mount::mount_to(demo_or_body(), || { view! { } - }) + }); + + unmount_handle.forget(); } diff --git a/examples/use_abs/Cargo.toml b/examples/use_abs/Cargo.toml index 8195e32..2f398ca 100644 --- a/examples/use_abs/Cargo.toml +++ b/examples/use_abs/Cargo.toml @@ -4,7 +4,10 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.6", features = ["nightly", "csr"] } +leptos = { git = "https://github.com/leptos-rs/leptos", features = [ + "nightly", + "csr", +] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" @@ -12,5 +15,5 @@ leptos-use = { path = "../..", features = ["docs", "math"] } web-sys = "0.3" [dev-dependencies] -wasm-bindgen = "0.2" -wasm-bindgen-test = "0.3.0" +wasm-bindgen = { workspace = true } +wasm-bindgen-test = { workspace = true } diff --git a/examples/use_abs/src/main.rs b/examples/use_abs/src/main.rs index 3570c0d..989fc62 100644 --- a/examples/use_abs/src/main.rs +++ b/examples/use_abs/src/main.rs @@ -27,7 +27,9 @@ fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); - mount_to(demo_or_body(), || { + let unmount_handle = leptos::mount::mount_to(demo_or_body(), || { view! { } - }) + }); + + unmount_handle.forget(); } diff --git a/examples/use_active_element/Cargo.toml b/examples/use_active_element/Cargo.toml index e5c31a5..a3775ed 100644 --- a/examples/use_active_element/Cargo.toml +++ b/examples/use_active_element/Cargo.toml @@ -4,7 +4,10 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.6", features = ["nightly", "csr"] } +leptos = { git = "https://github.com/leptos-rs/leptos", features = [ + "nightly", + "csr", +] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" @@ -12,5 +15,5 @@ leptos-use = { path = "../..", features = ["use_active_element", "docs"] } web-sys = { version = "0.3", features = ["HtmlElement", "DomStringMap"] } [dev-dependencies] -wasm-bindgen = "0.2" -wasm-bindgen-test = "0.3.0" +wasm-bindgen = { workspace = true } +wasm-bindgen-test = { workspace = true } diff --git a/examples/use_active_element/src/main.rs b/examples/use_active_element/src/main.rs index f8bea4a..6a9bb84 100644 --- a/examples/use_active_element/src/main.rs +++ b/examples/use_active_element/src/main.rs @@ -33,7 +33,9 @@ fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); - mount_to(demo_or_body(), || { + let unmount_handle = leptos::mount::mount_to(demo_or_body(), || { view! { } - }) + }); + + unmount_handle.forget(); } diff --git a/examples/use_and/Cargo.toml b/examples/use_and/Cargo.toml index b8a36ed..eb92b8c 100644 --- a/examples/use_and/Cargo.toml +++ b/examples/use_and/Cargo.toml @@ -4,7 +4,10 @@ version = "0.1.0" edition = "2021" [dependencies] -leptos = { version = "0.6", features = ["nightly", "csr"] } +leptos = { git = "https://github.com/leptos-rs/leptos", features = [ + "nightly", + "csr", +] } console_error_panic_hook = "0.1" console_log = "1" log = "0.4" @@ -12,5 +15,5 @@ leptos-use = { path = "../..", features = ["docs", "math"] } web-sys = "0.3" [dev-dependencies] -wasm-bindgen = "0.2" -wasm-bindgen-test = "0.3.0" +wasm-bindgen = { workspace = true } +wasm-bindgen-test = { workspace = true } diff --git a/examples/use_and/src/main.rs b/examples/use_and/src/main.rs index 703646f..d333224 100644 --- a/examples/use_and/src/main.rs +++ b/examples/use_and/src/main.rs @@ -11,7 +11,7 @@ fn Demo() -> impl IntoView { view! {
-