mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-02-02 10:54:15 -05:00
updated to latest version of web_sys
This commit is contained in:
parent
5d1d8ad28f
commit
294cbaf222
7 changed files with 36 additions and 39 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "leptos-use"
|
name = "leptos-use"
|
||||||
version = "0.11.4"
|
version = "0.11.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Marc-Stefan Cassola"]
|
authors = ["Marc-Stefan Cassola"]
|
||||||
categories = ["gui", "web-programming"]
|
categories = ["gui", "web-programming"]
|
||||||
|
@ -37,7 +37,7 @@ wasm-bindgen = "0.2.92"
|
||||||
wasm-bindgen-futures = "0.4"
|
wasm-bindgen-futures = "0.4"
|
||||||
|
|
||||||
[dependencies.web-sys]
|
[dependencies.web-sys]
|
||||||
version = "0.3"
|
version = ">=0.3.70"
|
||||||
features = [
|
features = [
|
||||||
"AddEventListenerOptions",
|
"AddEventListenerOptions",
|
||||||
"BinaryType",
|
"BinaryType",
|
||||||
|
|
|
@ -79,11 +79,10 @@ pub fn use_clipboard_with_options(
|
||||||
let update_text = move |_| {
|
let update_text = move |_| {
|
||||||
if is_supported.get() {
|
if is_supported.get() {
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
if let Some(clipboard) = window().navigator().clipboard() {
|
let clipboard = window().navigator().clipboard();
|
||||||
if let Ok(text) = js_fut!(clipboard.read_text()).await {
|
if let Ok(text) = js_fut!(clipboard.read_text()).await {
|
||||||
set_text.set(text.as_string());
|
set_text.set(text.as_string());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -102,13 +101,12 @@ pub fn use_clipboard_with_options(
|
||||||
let value = value.to_owned();
|
let value = value.to_owned();
|
||||||
|
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
if let Some(clipboard) = window().navigator().clipboard() {
|
let clipboard = window().navigator().clipboard();
|
||||||
if js_fut!(clipboard.write_text(&value)).await.is_ok() {
|
if js_fut!(clipboard.write_text(&value)).await.is_ok() {
|
||||||
set_text.set(Some(value));
|
set_text.set(Some(value));
|
||||||
set_copied.set(true);
|
set_copied.set(true);
|
||||||
start(());
|
start(());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,11 +235,11 @@ impl UseEventListenerOptions {
|
||||||
passive,
|
passive,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
let mut options = web_sys::AddEventListenerOptions::new();
|
let options = web_sys::AddEventListenerOptions::new();
|
||||||
options.capture(*capture);
|
options.set_capture(*capture);
|
||||||
options.once(*once);
|
options.set_once(*once);
|
||||||
if let Some(passive) = passive {
|
if let Some(passive) = passive {
|
||||||
options.passive(*passive);
|
options.set_passive(*passive);
|
||||||
}
|
}
|
||||||
|
|
||||||
options
|
options
|
||||||
|
|
|
@ -183,8 +183,8 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut event_src_opts = web_sys::EventSourceInit::new();
|
let event_src_opts = web_sys::EventSourceInit::new();
|
||||||
event_src_opts.with_credentials(with_credentials);
|
event_src_opts.set_with_credentials(with_credentials);
|
||||||
|
|
||||||
let es = web_sys::EventSource::new_with_event_source_init_dict(&url, &event_src_opts)
|
let es = web_sys::EventSource::new_with_event_source_init_dict(&url, &event_src_opts)
|
||||||
.unwrap_throw();
|
.unwrap_throw();
|
||||||
|
|
|
@ -214,20 +214,20 @@ impl From<UseMutationObserverOptions> for web_sys::MutationObserverInit {
|
||||||
character_data_old_value,
|
character_data_old_value,
|
||||||
} = val;
|
} = val;
|
||||||
|
|
||||||
let mut init = Self::new();
|
let init = Self::new();
|
||||||
|
|
||||||
init.subtree(subtree)
|
init.set_subtree(subtree);
|
||||||
.child_list(child_list)
|
init.set_child_list(child_list);
|
||||||
.attributes(attributes)
|
init.set_attributes(attributes);
|
||||||
.attribute_old_value(attribute_old_value)
|
init.set_attribute_old_value(attribute_old_value);
|
||||||
.character_data_old_value(character_data_old_value);
|
init.set_character_data_old_value(character_data_old_value);
|
||||||
|
|
||||||
if let Some(attribute_filter) = attribute_filter {
|
if let Some(attribute_filter) = attribute_filter {
|
||||||
let array = js_sys::Array::from_iter(attribute_filter.into_iter().map(JsValue::from));
|
let array = js_sys::Array::from_iter(attribute_filter.into_iter().map(JsValue::from));
|
||||||
init.attribute_filter(array.unchecked_ref());
|
init.set_attribute_filter(array.unchecked_ref());
|
||||||
}
|
}
|
||||||
if let Some(character_data) = character_data {
|
if let Some(character_data) = character_data {
|
||||||
init.character_data(character_data);
|
init.set_character_data(character_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
init
|
init
|
||||||
|
|
|
@ -171,8 +171,8 @@ pub struct UseResizeObserverOptions {
|
||||||
|
|
||||||
impl From<UseResizeObserverOptions> for web_sys::ResizeObserverOptions {
|
impl From<UseResizeObserverOptions> for web_sys::ResizeObserverOptions {
|
||||||
fn from(val: UseResizeObserverOptions) -> Self {
|
fn from(val: UseResizeObserverOptions) -> Self {
|
||||||
let mut options = web_sys::ResizeObserverOptions::new();
|
let options = web_sys::ResizeObserverOptions::new();
|
||||||
options.box_(
|
options.set_box(
|
||||||
val.box_
|
val.box_
|
||||||
.unwrap_or(web_sys::ResizeObserverBoxOptions::ContentBox),
|
.unwrap_or(web_sys::ResizeObserverBoxOptions::ContentBox),
|
||||||
);
|
);
|
||||||
|
|
|
@ -318,32 +318,31 @@ impl Default for UseWebNotificationOptions {
|
||||||
|
|
||||||
impl From<&UseWebNotificationOptions> for web_sys::NotificationOptions {
|
impl From<&UseWebNotificationOptions> for web_sys::NotificationOptions {
|
||||||
fn from(options: &UseWebNotificationOptions) -> Self {
|
fn from(options: &UseWebNotificationOptions) -> Self {
|
||||||
let mut web_sys_options = Self::new();
|
let web_sys_options = Self::new();
|
||||||
|
|
||||||
web_sys_options
|
web_sys_options.set_dir(options.direction.into());
|
||||||
.dir(options.direction.into())
|
web_sys_options.set_require_interaction(options.require_interaction);
|
||||||
.require_interaction(options.require_interaction)
|
web_sys_options.set_renotify(options.renotify);
|
||||||
.renotify(options.renotify)
|
web_sys_options.set_silent(options.silent);
|
||||||
.silent(options.silent);
|
|
||||||
|
|
||||||
if let Some(body) = &options.body {
|
if let Some(body) = &options.body {
|
||||||
web_sys_options.body(body);
|
web_sys_options.set_body(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(icon) = &options.icon {
|
if let Some(icon) = &options.icon {
|
||||||
web_sys_options.icon(icon);
|
web_sys_options.set_icon(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(image) = &options.image {
|
if let Some(image) = &options.image {
|
||||||
web_sys_options.image(image);
|
web_sys_options.set_image(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(language) = &options.language {
|
if let Some(language) = &options.language {
|
||||||
web_sys_options.lang(language);
|
web_sys_options.set_lang(language);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(tag) = &options.tag {
|
if let Some(tag) = &options.tag {
|
||||||
web_sys_options.tag(tag);
|
web_sys_options.set_tag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
web_sys_options
|
web_sys_options
|
||||||
|
|
Loading…
Add table
Reference in a new issue