mirror of
https://github.com/adoyle0/thaw.git
synced 2025-01-23 06:19:22 -05:00
save
This commit is contained in:
parent
c57748f9ea
commit
99f585440b
5 changed files with 16 additions and 9 deletions
|
@ -15,3 +15,6 @@ thaw = { version = "0.3.1", path = "./thaw" }
|
||||||
thaw_components = { version = "0.1.1", path = "./thaw_components" }
|
thaw_components = { version = "0.1.1", path = "./thaw_components" }
|
||||||
thaw_macro = { version = "0.1.0", path = "./thaw_macro" }
|
thaw_macro = { version = "0.1.0", path = "./thaw_macro" }
|
||||||
thaw_utils = { version = "0.0.3", path = "./thaw_utils" }
|
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" }
|
|
@ -12,7 +12,7 @@ license = "MIT"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
leptos = { version = "0.6.10" }
|
leptos = { workspace = true }
|
||||||
leptos_meta = { version = "0.6.10", optional = true }
|
leptos_meta = { version = "0.6.10", optional = true }
|
||||||
web-sys = "0.3.69"
|
web-sys = "0.3.69"
|
||||||
wasm-bindgen = "0.2.92"
|
wasm-bindgen = "0.2.92"
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
use ::wasm_bindgen::{prelude::Closure, JsCast};
|
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 std::ops::Deref;
|
||||||
use web_sys::EventTarget;
|
use web_sys::EventTarget;
|
||||||
|
|
||||||
pub fn add_event_listener<E: ev::EventDescriptor + 'static>(
|
pub fn add_event_listener<E>(
|
||||||
target: HtmlElement<AnyElement>,
|
target: impl DomRenderer,
|
||||||
event: E,
|
event: E,
|
||||||
cb: impl Fn(E::EventType) + 'static,
|
cb: impl Fn(E::EventType) + 'static,
|
||||||
) -> EventListenerHandle
|
) -> EventListenerHandle
|
||||||
where
|
where
|
||||||
|
E: ev::EventDescriptor + 'static,
|
||||||
E::EventType: JsCast,
|
E::EventType: JsCast,
|
||||||
{
|
{
|
||||||
add_event_listener_untyped(target, &event.name(), move |e| {
|
add_event_listener_untyped(target, &event.name(), move |e| {
|
||||||
|
@ -31,12 +35,12 @@ impl EventListenerHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_event_listener_untyped(
|
fn add_event_listener_untyped(
|
||||||
target: HtmlElement<AnyElement>,
|
target: impl DomRenderer,
|
||||||
event_name: &str,
|
event_name: &str,
|
||||||
cb: impl Fn(web_sys::Event) + 'static,
|
cb: impl Fn(web_sys::Event) + 'static,
|
||||||
) -> EventListenerHandle {
|
) -> EventListenerHandle {
|
||||||
fn wel(
|
fn wel(
|
||||||
target: HtmlElement<AnyElement>,
|
target: impl DomRenderer,
|
||||||
cb: Box<dyn FnMut(web_sys::Event)>,
|
cb: Box<dyn FnMut(web_sys::Event)>,
|
||||||
event_name: &str,
|
event_name: &str,
|
||||||
) -> EventListenerHandle {
|
) -> EventListenerHandle {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use leptos::{MaybeSignal, Memo, ReadSignal, RwSignal, Signal};
|
use leptos::prelude::{MaybeSignal, Memo, ReadSignal, RwSignal, Signal};
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
pub struct OptionalProp<T>(Option<T>);
|
pub struct OptionalProp<T>(Option<T>);
|
||||||
|
@ -99,7 +99,7 @@ impl<T> From<Option<T>> for OptionalProp<T> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::OptionalProp;
|
use super::OptionalProp;
|
||||||
use leptos::MaybeSignal;
|
use leptos::prelude::MaybeSignal;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn from() {
|
fn from() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use leptos::{leptos_dom::helpers::TimeoutHandle, *};
|
use leptos::{leptos_dom::helpers::TimeoutHandle, prelude::*};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
pub fn throttle(cb: impl Fn() + 'static, duration: Duration) -> impl Fn() -> () {
|
pub fn throttle(cb: impl Fn() + 'static, duration: Duration) -> impl Fn() -> () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue