From 99f585440b96929c292c19bfabc51907480699e7 Mon Sep 17 00:00:00 2001 From: luoxiao Date: Wed, 12 Jun 2024 17:36:34 +0800 Subject: [PATCH] save --- Cargo.toml | 3 +++ thaw_utils/Cargo.toml | 2 +- thaw_utils/src/event_listener.rs | 14 +++++++++----- thaw_utils/src/optional_prop.rs | 4 ++-- thaw_utils/src/throttle.rs | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5df07a6..85c6708 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,3 +15,6 @@ thaw = { version = "0.3.1", path = "./thaw" } thaw_components = { version = "0.1.1", path = "./thaw_components" } thaw_macro = { version = "0.1.0", path = "./thaw_macro" } thaw_utils = { version = "0.0.3", path = "./thaw_utils" } + +leptos = { git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7" } +leptos_meta = { git = "https://github.com/leptos-rs/leptos", branch = "leptos_0.7" } \ No newline at end of file diff --git a/thaw_utils/Cargo.toml b/thaw_utils/Cargo.toml index ad14846..8a60343 100644 --- a/thaw_utils/Cargo.toml +++ b/thaw_utils/Cargo.toml @@ -12,7 +12,7 @@ license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -leptos = { version = "0.6.10" } +leptos = { workspace = true } leptos_meta = { version = "0.6.10", optional = true } web-sys = "0.3.69" wasm-bindgen = "0.2.92" diff --git a/thaw_utils/src/event_listener.rs b/thaw_utils/src/event_listener.rs index 965c58c..9afdc19 100644 --- a/thaw_utils/src/event_listener.rs +++ b/thaw_utils/src/event_listener.rs @@ -1,14 +1,18 @@ use ::wasm_bindgen::{prelude::Closure, JsCast}; -use leptos::{html::AnyElement, *}; +use leptos::{ + ev, + tachys::{renderer::DomRenderer, view::any_view::AnyView}, +}; use std::ops::Deref; use web_sys::EventTarget; -pub fn add_event_listener( - target: HtmlElement, +pub fn add_event_listener( + target: impl DomRenderer, event: E, cb: impl Fn(E::EventType) + 'static, ) -> EventListenerHandle where + E: ev::EventDescriptor + 'static, E::EventType: JsCast, { add_event_listener_untyped(target, &event.name(), move |e| { @@ -31,12 +35,12 @@ impl EventListenerHandle { } fn add_event_listener_untyped( - target: HtmlElement, + target: impl DomRenderer, event_name: &str, cb: impl Fn(web_sys::Event) + 'static, ) -> EventListenerHandle { fn wel( - target: HtmlElement, + target: impl DomRenderer, cb: Box, event_name: &str, ) -> EventListenerHandle { diff --git a/thaw_utils/src/optional_prop.rs b/thaw_utils/src/optional_prop.rs index eca37c6..ffb5daf 100644 --- a/thaw_utils/src/optional_prop.rs +++ b/thaw_utils/src/optional_prop.rs @@ -1,4 +1,4 @@ -use leptos::{MaybeSignal, Memo, ReadSignal, RwSignal, Signal}; +use leptos::prelude::{MaybeSignal, Memo, ReadSignal, RwSignal, Signal}; use std::ops::{Deref, DerefMut}; pub struct OptionalProp(Option); @@ -99,7 +99,7 @@ impl From> for OptionalProp { #[cfg(test)] mod test { use super::OptionalProp; - use leptos::MaybeSignal; + use leptos::prelude::MaybeSignal; #[test] fn from() { diff --git a/thaw_utils/src/throttle.rs b/thaw_utils/src/throttle.rs index 0c970ae..a71e061 100644 --- a/thaw_utils/src/throttle.rs +++ b/thaw_utils/src/throttle.rs @@ -1,4 +1,4 @@ -use leptos::{leptos_dom::helpers::TimeoutHandle, *}; +use leptos::{leptos_dom::helpers::TimeoutHandle, prelude::*}; use std::time::Duration; pub fn throttle(cb: impl Fn() + 'static, duration: Duration) -> impl Fn() -> () {